Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
cycling through columns?
I want to know if it is possible to numerically cycle through the columns.
You can do this with cells, by using range (x,y) which allows you to reference columns and rows numerically. I want to be able to reference the column numerically so that I can set widths based on what column number I am in. I want to be able to do something like this For x = 1 to totnumofcolumnsbeingused if x = 5 or x = 9 then set the width of the 5th or 9th column to 15 end if next x is this possible? Any help would be appreciated. Thanks. Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
cycling through columns?
Dim i as Long
for i = 1 to 256 if i = 5 or i = 9 then msgbox Columns(i).Address end if Next You can also do Dim i as long, col as Range for i = 1 to 256 set col = cells(1,i).EntireColumn if i = 5 or i = 6 then msgbox col.Address end if Next -- Regards, Tom Ogilvy "Kirk" wrote in message ... I want to know if it is possible to numerically cycle through the columns. You can do this with cells, by using range (x,y) which allows you to reference columns and rows numerically. I want to be able to reference the column numerically so that I can set widths based on what column number I am in. I want to be able to do something like this For x = 1 to totnumofcolumnsbeingused if x = 5 or x = 9 then set the width of the 5th or 9th column to 15 end if next x is this possible? Any help would be appreciated. Thanks. Kirk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
cycling through columns?
Tom,
Thanks that worked. Kirk "Tom Ogilvy" wrote: Dim i as Long for i = 1 to 256 if i = 5 or i = 9 then msgbox Columns(i).Address end if Next You can also do Dim i as long, col as Range for i = 1 to 256 set col = cells(1,i).EntireColumn if i = 5 or i = 6 then msgbox col.Address end if Next -- Regards, Tom Ogilvy "Kirk" wrote in message ... I want to know if it is possible to numerically cycle through the columns. You can do this with cells, by using range (x,y) which allows you to reference columns and rows numerically. I want to be able to reference the column numerically so that I can set widths based on what column number I am in. I want to be able to do something like this For x = 1 to totnumofcolumnsbeingused if x = 5 or x = 9 then set the width of the 5th or 9th column to 15 end if next x is this possible? Any help would be appreciated. Thanks. Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Tab keeps cycling through the same row | Excel Discussion (Misc queries) | |||
Cycling through workbooks | Excel Discussion (Misc queries) | |||
Cycling through variables. | Excel Programming | |||
Cycling though all sheets in the workbook | Excel Programming | |||
Cycling through worksheets | Excel Programming |