I am a newbee in VBA, I have a problem that how to how to loop ranges in VBA for example: Range("A1:D1").select
to Range("A100:D100").select
or
Range("A1:D1").select
to Range("D1:G1").select
?
Note : it is better to avoid using Select
, Activate
, etc...
To loop through ranges that changes per row, use the For
loop through lRow
below:
' loop example per your case
For lRow = 1 To 100
Range("A" & lRow & ":D" & lRow).Select
Next lRow
To loop through ranges that changes per column, use the For
loop through Col
below:
' loop example per your case
For Col = 1 To 4
Range(Cells(1, Col), Cells(1, Col + 3)).Select
Next Col
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.