Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab keeps cycling through the same row Mike Excel Discussion (Misc queries) 2 August 14th 08 12:20 AM
Cycling through workbooks Nico Excel Discussion (Misc queries) 4 July 4th 08 10:09 PM
Cycling through variables. Azza Excel Programming 1 October 14th 04 10:23 PM
Cycling though all sheets in the workbook James[_14_] Excel Programming 5 February 27th 04 04:11 PM
Cycling through worksheets Chris Gorham[_3_] Excel Programming 2 November 5th 03 08:37 PM


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"