Changes and comments/suggestions
Option Explicit Sub example() 'better not to use VBA reserved words, less confusing Dim rCell As Range 'as it was, whatever the activesheet was would be used .need the dot on the Range(A2)'s With Worksheets("Sheet1") 'the Range around (A2) was missing For Each rCell In Range(.Range("A2"), .Range("A2").End(xlDown)) rCell.Font.Color = 255 Next End With End Sub
Suggestion: by starting in A2 and going down, the selection will end at a cell above a blank cell, and if there are data filled cells below, they won't be included
I've found it's safer to start at the bottom of the worksheet and go up to make the end cell the one with data
Sub example2() Dim rCell As Range, rColor As Range With Worksheets("Sheet1") Set rColor = .Range("A2") Set rColor = Range(rColor, .Cells(.Rows.Count, 1).End(xlUp)) 'the Range around (A2) was missing For Each rCell In rColor.Cells rCell.Font.Color = 255 Next End With End Sub




Reply With Quote