I'm getting hung up on syntax, so am asking for help. I have the following variables:
Dim FirstCol As Long
Dim LastCol As Long
FirstCol is my selected column, which can be anywhere on the page, OR FirstCol is Column A (choice is up to the user)
LastCol is the last populated column on the activesheet
In my selected column, I'm stepping down through the cells to determine which cells are duplicates, to color those with alternating bands of color. My code below works great for the selected column, but I want to color the range from FirstCol to LastCol within the rows currently selected by the macro, and can't figure out how to phrase that. Your help is greatly appreciated.
TC = 1
For row = TopCell To LastCell
If TC = 1 Then
Color = TxtColor1
Else
Color = TxtColor2
End If
If Cells(row, Selection.Column).Value = Cells(row + 1, Selection.Column).Value Then
Selection.Resize(Selection.Cells.Count + 1).Select
Else
If Selection.Cells.Count > 1 Then
Selection.Interior.Color = Color
Cells(row + 1, Selection.Column).Select
TC = TC + 1
If TC = 3 Then TC = 1
Else
Cells(row + 1, Selection.Column).Select
End If
End If
Next row
Bookmarks