I'm using the below code to shade rows, but right now it's only coloring the first cell in B12. I'd like to shade the row from B to the last used column
Private Const StartRow As Long = 12 'row to start coloring
Private Const EndRow As Long = -2 '-1 'if you put -1, it will calculate the last row by finding the last row in Column A
Private Const RGBColor As Long = 16053492 'RGB(255, 255, 255)
Private Const RowIncrementor As Integer = 1 ' This incrementer will be used to decide the gap between the rows to be colored.
Sub ColorRow()
Dim lastRow As Long
Dim activeSht As Worksheet
Dim rowCounter As Long
lastRow = EndRow
Set activeSht = ActiveSheet
If (lastRow = -2) Then
'the last row has to be calculated
lastRow = activeSht.UsedRange(Rows.Count, 2).End(xlUp).Row
End If
'create a loop to color rows now
For rowCounter = StartRow To lastRow Step RowIncrementor + 1
activeSht.Range("B" & rowCounter).Interior.Color = RGBColor
Next rowCounter
End Sub
Bookmarks