Ok, give this one a shot... I have also provided a workbook_beforesave macro, so that on saving it does not save with the column highlighted (I believe... leaving final testing to you). The only thing is.... to avoid saving with highlight, the variables that store the old column and colour need to be public variables, and you are not allowed to have public variables in events. So in a normal module, at the top, put:
Public colno As Long
Public colcolour(1 To 100)
Then in the sheet's code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
If colno > 0 And colcolour(1) <> 0 Then
For i = 1 To 100
If colcolour(i) <> xlNone Then Cells(i, colno).Interior.Color = colcolour(i)
If colcolour(i) = xlNone Then Cells(i, colno).Interior.ColorIndex = xlNone
Next i
End If
colno = Target.Column
For i = 1 To 100
If Cells(i, Target.Column).Interior.ColorIndex <> xlNone Then colcolour(i) = Cells(i, Target.Column).Interior.Color
If Cells(i, Target.Column).Interior.ColorIndex = xlNone Then colcolour(i) = xlNone
Next i
With Target
' Highlight the entire row and column that contain the active cell
.EntireColumn.Interior.ColorIndex = 43
End With
Application.ScreenUpdating = True
End Sub
And then in "ThisWorkbook" :
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ScreenUpdating = False
If colno > 0 And colcolour(1) <> 0 Then
For i = 1 To 100
If colcolour(i) <> xlNone Then Cells(i, colno).Interior.Color = colcolour(i)
If colcolour(i) = xlNone Then Cells(i, colno).Interior.ColorIndex = xlNone
Next i
End If
Application.ScreenUpdating = True
End Sub
Bookmarks