Macro to select column if a cell in row 1 = Duration

G

GTVT06

Hello,
Can someone help me create a macro? I would like to create a macro that
will search Row 1 for "Duration" and once it finds out which column
it's in, I want it to select the whole column.
I want to use the macro to format the duration column and use the macro
on multiple workbooks and the duration column varies from book to book.

Thanks,
 
B

Bob Phillips

Dim iColumn As Long
On Error Resume Next
iColumn = Application.Match("Duration", Rows(1), 0)
On Error GoTo 0
If iColumn > 0 Then
Columns(iColumn).Select
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
G

GTVT06

Worked like a charm. Thanks!!!


Bob said:
Dim iColumn As Long
On Error Resume Next
iColumn = Application.Match("Duration", Rows(1), 0)
On Error GoTo 0
If iColumn > 0 Then
Columns(iColumn).Select
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top