gsouza
08-16-2005, 04:45 AM
Hi everybody, hope you can help. This is what I have for a code to highlight a cell I select.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("a1:a25")) Is Nothing Then
Cells.Interior.ColorIndex = xlColorIndexNone
Selection.Interior.ColorIndex = 8
End If
End Sub
What I don't want to do is put a range Range("a1:a25")) , if i have data in column "A" and the last row is 5, I want the range that get highlighted to stop at row 5 only. I don't want the range to be longer than the cells in that column to be longer than what is populated. I don't want to have to go back to VBE and have to manually change the range.
I hope this makes sense, thanks in advance for any help I get.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("a1:a25")) Is Nothing Then
Cells.Interior.ColorIndex = xlColorIndexNone
Selection.Interior.ColorIndex = 8
End If
End Sub
What I don't want to do is put a range Range("a1:a25")) , if i have data in column "A" and the last row is 5, I want the range that get highlighted to stop at row 5 only. I don't want the range to be longer than the cells in that column to be longer than what is populated. I don't want to have to go back to VBE and have to manually change the range.
I hope this makes sense, thanks in advance for any help I get.