I'm still playing around and trying to explore the VBA ocean :cry:
The code below is self explanatory but it does not undo the border related formatting. Can you please guide and help me figure out my mistake. The attached image shows the worksheet that I am using.
Sub Exercise5() ' This code is supposed to do the following: ' If the cell is highlighted with yellow fill, format it's borders, display a dialog Box/MsgBox ' with some information about the cell and when the user clicks OK on the MsgBox, ' it should [B][SIZE="4"]undo[/SIZE][/B] all border related formatting Dim Rng As Range, MyCell As Range Dim irow As Long Application.ScreenUpdating = False Set Rng = Worksheets(1).Cells(1, 1) irow = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row Set Rng = Rng.Resize(irow - Rng.Row + 1, 1) On Error Resume Next For Each MyCell In Rng.Cells If MyCell.Interior.ColorIndex = 6 Then [B][COLOR="Red"][SIZE="4"]' Tried both of the following lines MyCell.Activitate and MyCell.Select ' but could not get the cell to be selected. ' Can you please help me understand why I am unable to ' get the cell highlighted?[/SIZE][/COLOR][/B] ' MyCell.Select ' MyCell.Activate With MyCell .BorderAround LineStyle:=xlDash, Weight:=xlThick, ColorIndex:=5 End With MsgBox "Cell Address = " & MyCell.Address & vbLf & _ "Interior.ColorIndex = " & MyCell.Interior.ColorIndex & vbLf & _ "Cell.Value = " & MyCell.Value '[B][COLOR="Red"]The code below [B][SIZE="4"]does not undo[/SIZE][/B] the border related formatting that was done above[/COLOR][/B] With MyCell .BorderAround LineStyle:=xlContinuous, Weight:=xlThin, [INDENT][INDENT][INDENT]_ColorIndex:=xlColorIndexAutomatic[/INDENT][/INDENT][/INDENT] End With End If Next MyCell Application.ScreenUpdating = True End Sub