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

  • Thread starter Thread starter GTVT06
  • Start date Start date
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,
 
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)
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top