ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA-How do I increment columns in VBA? (https://www.excelbanter.com/excel-programming/290414-excel-vba-how-do-i-increment-columns-vba.html)

waveracerr[_4_]

Excel VBA-How do I increment columns in VBA?
 
I want to run a macro that cycles through columns within a For loop. I
can do this within a range no problem. How to do it in columns
though...I don't know. Any help?

Eg. For i=1 To 4
Range("A" & (i), "BB" & (i)).Select
Next i

How can I have this code cycle through columns? Thanks!

Ryan


---
Message posted from http://www.ExcelForum.com/


Bob Phillips[_6_]

Excel VBA-How do I increment columns in VBA?
 
For i = 1 To 4
Columns(i).Select
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"waveracerr " wrote in message
...
I want to run a macro that cycles through columns within a For loop. I
can do this within a range no problem. How to do it in columns
though...I don't know. Any help?

Eg. For i=1 To 4
Range("A" & (i), "BB" & (i)).Select
Next i

How can I have this code cycle through columns? Thanks!

Ryan


---
Message posted from http://www.ExcelForum.com/




Eloy

Excel VBA-How do I increment columns in VBA?
 
try this:

Eg. For i=1 To 4
Range(cells(1,i),cells(1,i)).Select
Next i

cheers
e


All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com