0

I am trying to define a cell range (i.e. A1:F1) using the number from my iCounter as the row number.

Presently, my code is formatted like

Range(A & (iCounter - 2):F1 & (iCounter - 1)).Select

I am getting the Syntax Error statement. I have researched and reformatted with quotation marks but I am still unable to get the format correct.

I have based this on a recording that used the hard coded:

Range("A1:F1").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark2
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub

The code block I have adapted is below. Thank you!

Step 5:  Start reverse looping through the range.
    For iCounter = MyRange.Rows.Count To 2 Step -3
    
'Step 6: Copy and Paste columns
        '
        Range("A" & (iCounter - 1)).Cut Range("A" & (iCounter - 2))
        'Add a color fill
        Range(A & (iCounter - 2):F1 & (iCounter - 1)).Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorDark2
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With

        
'Step 7: Increment the counter down
    Next iCounter
BigBen
  • 46,229
  • 7
  • 24
  • 40
user3324136
  • 415
  • 5
  • 20

0 Answers0