Find header name

D

darkblue

I have 7 columns and under them my data, each column has their own
data.
Row 2 contains the header names of the underlying data.
I'd to find, for instance, "metropol bus" on the sheet first and then
header name resides on the second row on the same column "buses".
How can I do this by vba ? Any hint or direction ?
 
R

Ryan H

Hope this helps! If so, let me know, click "YES" below.

Option Explicit

Sub GetHeaderName()

Dim HeadColumn As Long

HeadColumn = Sheets("Sheet1").Cells.Find(What:="metropol bus", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Column

MsgBox "Header Name is - " & Sheets("Sheet1").Cells(2, HeadColumn)

End Sub
 

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

Top