ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find header name (https://www.excelbanter.com/excel-programming/438452-find-header-name.html)

darkblue

Find header name
 
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 ?

Ryan H

Find header name
 
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
--
Cheers,
Ryan


"darkblue" wrote:

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 ?
.


darkblue

Find header name
 
Couldn't find DOUBLE YES to click.
Thank you very much Ryan.


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com