Highlighting active cell
Posted by Charlie Carroll on July 27, 2001 10:16 PM
Since some of my users complained that they weren't always sure where the cursor was and I couldn't change their setups, I pursued highligting the active cell so long as there wasn't any conditional formatting in it (which would have taken precedence anyway). Also needed to turn it back to colorless unless the interior color was changed from whatever highlight color I used during processing in the active cell. Working with a programmer, we developed the macro below. I decided I wanted to put it in my own personal.xls. Did so and found it working fine in personal.xls but not carrying over to new sheets. Made the obvious change to "Public" from "Private" and got compile errors. Turned it back to "Private" and now find it still works fine in personal.xls only but that it puts a power blue (the color (20) I happened to choose in A1 on new sheets but doesn't move the highligted cell. I believe this is a "dumb pet trick" which would be very popular with most users and would like some help on figuring out what we have done wrong.
Public address1 As Integer
Public address2 As Integer
Private Sub Workbook_Open()
ActiveCell.Interior.ColorIndex = 20
address1 = ActiveCell.Row
address2 = ActiveCell.Column
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
ActiveCell.Interior.ColorIndex = 20
If address1 <> 0 And address2 <> 0 Then
ActiveSheet.Cells(address1, address2).Interior.ColorIndex = xlNone
End If
address1 = Target.Row
address2 = Target.Column
End Sub