View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default excel columns collection?

There's a range object you can use:

dim Col as range
dim cols as range

set cols = range("a:j")
'I like that better than columns("a:j"), but it won't matter.

for each col in cols.columns
col.columnwidth = 10
next col

but why not just:

columns("a:j").columnwidth = 10

===
I changed it to .columnwidth, too.


Ron wrote:

Just checking if there is such a collection in excel as a
columns collection. I want to loop through a columns
collection for formatting.

Pseudocode

Dim col As Column, cols As Columns
Set cols = Columns(A:J)
For each col in cols
col.width = 10
Next

Is there a way to do something like this?

Thanks,
Ron


--

Dave Peterson