Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel columns collection?
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
excel columns collection?
I think I figured this out
Dim sht As WorkSheet, i As Integer, col As Variant Set sht = Sheets("Sheet1") For i = 1 to sht.Columns("A:J").Count sht.Columns(i).ColumnWidth = 11.5 Next '--or For each col in Sht.Columns("A:J") Debug.print col.ColumnWidth Next -----Original 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 . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A link to a collection of videos and tutorials on MS excel:Add-in. | Excel Discussion (Misc queries) | |||
Excel data collection | Excel Discussion (Misc queries) | |||
Excel 2003 macro collection | Excel Discussion (Misc queries) | |||
how do i create a data collection form in excel? | New Users to Excel | |||
Keybindings Collection in Excel | Excel Programming |