
Originally Posted by
Junoon
i have made global string constants for ranges.
PHP Code:
Global Const G_Cl As String = "G2:G13"
Global Const G_Vl As String = "I2:I13"
Global Const G_VlS As String = "L2:L13"
i want to clear these ranges using a single line of code.
PHP Code:
With wkData
.Range(G_Cl, G_Vl, G_VlS).ClearContents
End With
but i get error:
If you did it without using the constants, this is how the code line would look...
Code:
.Range("G2:G13,I2:I13,L2:L13").ClearContents
To duplicate this structure, you have to concatenate the constants together using commas between them in order to get the right syntax for the multiple ranges within the Range call. Try it like this...
Code:
With wkData
.Range(G_Cl & "," & G_Vl & "," & G_VlS).ClearContents
End With
Bookmarks