Find header name

  • Thread starter Thread starter darkblue
  • Start date Start date
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 ?
 
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
 
Back
Top