View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default excel columns collection?

Ron,

This may be more specific than you want, but it works for the situation you
describe:

Range("A1:J1").ColumnWidth = 2

More generally, no, there is no columns collection. Instead define ranges
and then use the .column or .entirecolumn or similar properties of those
ranges, e.g.,:

Sub test()
Dim col As Range
For Each col In Range("A1:J1")
col.ColumnWidth = 2
Next
End Sub

hth,

Doug

"Ron" wrote in message
...
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