PDA

View Full Version : What does line 7 mean



Aussiebear
01-01-2022, 07:18 PM
Sub range_demo()
'declare variable
Dim lastrow As Integer
'initialize variable
lastrow = ActiveSheet.UsedRange.Rows.Count
'Use the variable in the range expression to select
Sheets("Wonders").Range("A2:C" & lastrow).Select
'colour the selected cells in green
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274 'green colour
End With

End Sub

rollis13
01-02-2022, 04:14 AM
& is not valid syntax in vba; I believe it's only a forum software bug misinterpreting a single "&".

Paul_Hossler
01-02-2022, 07:05 AM
I'm guessing that the code came from a HTML source since '&' is the HTML entity for an 'ampersand' and was pasted in as is

Don't know why there's 3 of them

I'd guess the syntax should be



Sub range_demo()
'declare variable
Dim lastrow As Integer
'initialize variable
lastrow = ActiveSheet.UsedRange.Rows.Count
'Use the variable in the range expression to select
Sheets("Wonders").Range("A2:C" & lastrow).Select
'colour the selected cells in green
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274 'green colour
End With

End Sub