Hello all!
Looking for some help with a VBA. I want to highlight both row and columns of the selected cell and the below code is working however I was wondering if it is possible to control when the VBA is running. IE by putting "OFF" in cell A1 then the VBA would not run.
Thanks
Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.FindFormat.Interior.Color = RGB(236, 236, 236)
Application.ReplaceFormat.Interior.Color = xlNone
Cells.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.FindFormat.Interior.Color = xlNone
Application.ReplaceFormat.Interior.Color = RGB(236, 236, 236)
Target.EntireRow.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Target.EntireColumn.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.ScreenUpdating = True
End Sub
Looking for some help with a VBA. I want to highlight both row and columns of the selected cell and the below code is working however I was wondering if it is possible to control when the VBA is running. IE by putting "OFF" in cell A1 then the VBA would not run.
Thanks
Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.FindFormat.Interior.Color = RGB(236, 236, 236)
Application.ReplaceFormat.Interior.Color = xlNone
Cells.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.FindFormat.Interior.Color = xlNone
Application.ReplaceFormat.Interior.Color = RGB(236, 236, 236)
Target.EntireRow.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Target.EntireColumn.Replace "", "", SearchFormat:=True, ReplaceFormat:=True
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Application.ScreenUpdating = True
End Sub