I would like to use variables within the range function, to assign adaptive range selection in excel VBA.
Range("A"&aa+4":C5"&bb+4).Select
where aa and bb are variables.
Thanks !
Try using this:
Range("A" + Strings.Trim(Str(aa + 4)) + ":C" + Strings.Trim(Str(bb + 4))).Select
or this:
Range(Cells(aa + 4, 1), Cells(bb + 4, 3)).Select
Also there is an article I've written on my blog about the different methods of referencing ranges in excel using VBA which covers this topic. Referencing Ranges in Excel Using VBA
Range("A" & aa+4 & ":C" & bb+4).Select?&after the first4to have a proper concatenation. And please try to avoid using.Selectyou will find many resources on this with a quick search