Reputation: 153
So here is my problem. I know we can define a range in VBA, say for example like Range("A1:A300"). Now say I have some integer x. I want the range from A1 to Ax. How can I write this in a code? Range("A1:Ax") clearly does not work
Upvotes: 1
Views: 20747
Reputation: 175956
You can specify the anchor cell then extend:
range("A1").resize(300)
Upvotes: 2
Reputation: 882606
That would be something like:
Range("A1:A" & CStr(x))
The CStr
function will turn an integer into a string though I think you can actually just leave it off in later versions of Excel:
Range("A1:A" & x)
Upvotes: 1