aoc
06-09-2011, 11:39 PM
Dear All,
What should I do if I want below code run automatically whenever I open a new workbook ? And there is a problem. When I select a cell it is coloured If I save the file and close and reopen the cell is still coloured how can I prevent this ?
Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 3
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target
End Sub
What should I do if I want below code run automatically whenever I open a new workbook ? And there is a problem. When I select a cell it is coloured If I save the file and close and reopen the cell is still coloured how can I prevent this ?
Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 3
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target
End Sub