PDA

View Full Version : select column by referencing column title



RobertHT
03-02-2009, 03:19 PM
Hi i have a spreadsheet with Columns that have specific names. These columns may come in any order and my aim is to sort them in a standard order for processing (using there title). I can't use column letter reference as these columns may come arrive in any order.

thanks in advance...

mdmackillop
03-02-2009, 04:02 PM
Something like
Sub ProcessColumns()
Dim Arr, a
Arr = Array("Col1", "Col2", "Col3", "Col4")
For Each a In Arr
Range(a).EntireColumn.Interior.ColorIndex = 6
Next

End Sub

Paul_Hossler
03-02-2009, 06:36 PM
I do something like that also

1. Loop through my array of col headers

2. MATCH in the first row to find the col number of each of my headers

3. copy and paste that col into a new sheet, starting in col 1, etc

4. delete the original sheet and rename the added on to that name

I can do a test WB if you want more info

Paul