Search a Row and return Header Row Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a spreadsheet with 60 columns of data, each with a unique header
label. What formula do I use to search each row for specific data, then,
upon finding a match, return the header label data (i.e. the info in Row 1 of
that particular column.)

Thanks!
 
Here is a custom function

call with =GetHeader(10.50,A3:D8,1)
where
10.50 is the data you arre looking for
A3:D8 is range of cells to search
1 is the row of sheet youwant to get data from.

Routine locates the column whre the data is found and then returns the data
in the the same column for the row specified

Function GetHeader(SearchData As Variant, Target As Range, RowNumber)

For Each cell In Target
If SearchData = cell.Value Then Exit For

Next cell

GetHeader = Cells(RowNumber, cell.Column).Value

End Function
 
With the data to match in A2 and your 60 columns in b:bi

=index($b$1:$bi$1,match(a2,$b2:$bi2,0))
 

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