Compile Error

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Compile Error

Post by VegasNath »

Code: Select all

    Range(("B8:" & iCol & "8"), _
        ("B22:" & iCol & "22"), _
        ("B48:" & iCol & "48"), _
        ("B53:" & iCol & "53"), _
        ("B57:" & iCol & "57"), _
        ("B65:" & iCol & "65")).Interior.ColorIndex = 36
Why does this not work? :scratch:
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Compile Error

Post by HansV »

It the entire range should be one string:

Code: Select all

    Range("B8:" & iCol & "8," & _
        "B22:" & iCol & "22," & _
        "B48:" & iCol & "48," & _
        "B53:" & iCol & "53," & _
        "B57:" & iCol & "57," & _
        "B65:" & iCol & "65").Interior.ColorIndex = 36
Apart from that, the variable name iCol would traditionally be used for an integer because of the prefix "i", but in this code, it needs to be a string. This is bound to confuse more experienced programmers, so I'd use sCol or strCol instead of iCol.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Compile Error

Post by VegasNath »

Thanks Hans, works great, and I appreciate the advice.
:wales: Nathan :uk:
There's no place like home.....