Hi there,
I'd be grateful for any help with the following coding problem.
I wanted to auto highlight the active row and column in my spreadsheet to make it easier to see the row/column position when entering data.
I found the following code which did the trick. Almost.
Private Sub Worksheet_Activate()
End Sub
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' 4. We declare four variables of type Integer. One named rowNumberValue, one named columnNumberValue, one
' named i and one named j.
Dim rowNumberValue As Integer, columnNumberValue As Integer, i As Integer, j As Integer
' 5. First, we add the line which changes the background color of all cells to 'No Fill'.
Cells.Interior.ColorIndex = 0
' 6. We initialize the variable rowNumberValue with the row number of the Active Cell and the variable
' columnNumberValue with the column number of the Active Cell.
rowNumberValue = ActiveCell.Row
columnNumberValue = ActiveCell.Column
' 7. We highlight the column blue. That is: all the cells with row number smaller or equal to rowNumberValue and
' column number equal to columnNumberValue
For i = 5 To rowNumberValue
Cells(i, columnNumberValue).Interior.ColorIndex = 37
Next i
' 8. In a similar way, we highlight the row blue. That is: all the cells with row number equal to rowNumberValue and
' column number smaller or equal to columnNumberValue.
For j = 4 To columnNumberValue
Cells(rowNumberValue, j).Interior.ColorIndex = 37
Next j
End Sub
However, I don't want the 'no fill' command (5) to wipe out the colour coding I have set up in rows 1-4, as these are my header rows and the colour coding is very useful to me. How do I change the 'no fill' to be applicable to the range A5:CZ627 only?
Many thanks for your time.
Crabman9
Bookmarks