Lookup Column (Header) name in Excel for a given cell

user4581436

I have one workbook with many order numbers in many different columns(20+). Each Column has a different Header(column name) that can be found in the first row.

On a different sheet I will have all of the order numbers compiled into column A. In column B I would populate the name of the column (header) for each order number.

The code below would provide me a function to return the sheet name. In line 14 I tried changing w.s. name to header but it would not work.

Option Explicit
Function FindMyOrderNumber(strOrder As String) As String

    Dim ws As Worksheet
    Dim rng As Range
    Application.Volatile
    For Each ws In Worksheets
        If ws.CodeName <> "Sheet3" Then
            Set rng = Nothing
            On Error Resume Next
            Set rng = ws.Cells.Find(What:=strOrder, LookAt:=xlWhole)
            On Error GoTo 0
            If Not rng Is Nothing Then
                FindMyOrderNumber = ws.Name
                Exit For
            End If
        End If
Next

Set rng = Nothing
Set ws = Nothing

End Function
Lance Roberts
FindMyOrderNumber = ws.Cells(1, rng.Column)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the last value of a the given header name column in Excel

From Dev

Excel find closest bigger value in a column to a given lookup value

From Dev

Excel formula to lookup the last value in a column and return the value of the adjacent cell

From Dev

Get Cell Value with column name in Php Excel

From Dev

Excel - Inserting cell value in formula column name

From Dev

Lookup cell reference of given value

From Dev

Refer to Excel cell in Table by header name and row number

From Dev

Pandas Read Excel: how to access a given cell by column and row numbers

From Dev

Pandas Read Excel: how to access a given cell by column and row numbers

From Dev

(Excel) Finding the column header associated with a cell, returning a list of names and headers

From Dev

Excel: If a cell = 0 then display the last entries, column header

From Dev

In a table with row headers and column headers, given a column header text and a cell text, how can I select a cell (td)?

From Dev

Excel VBA Find column name of first blank cell in row

From Dev

Referencing cell only by column name in Excel 2010 VBA

From Dev

Find out Excel column character from name of cell in first row

From Dev

if name appears in FILTER formula column, then lookup email addresses and combine all in one cell

From Dev

Find Column Header By Name And Select All Data Below Column Header (Excel-VBA)

From Dev

ASP VB.NET GridView: Change Column cell text by column header name with AutogenerateColumn = True

From Dev

Excel Find Cell Name

From Dev

Select the column header if cell is formula

From Dev

DataGridViewAutoFilter Resize Column Header Cell

From Dev

If cell contains value then 'Column header'

From Dev

Select the column header if cell is formula

From Dev

Using Lookup in Excel to populate column

From Dev

Get column header and row header on cell click

From Dev

Row header and column header for a particular cell in table

From Dev

Renaming column header in Excel

From Dev

Lookup last non blank cell in column excluding ""

From Dev

Excel VBA function to lookup value in a Cell range

Related Related

  1. 1

    Get the last value of a the given header name column in Excel

  2. 2

    Excel find closest bigger value in a column to a given lookup value

  3. 3

    Excel formula to lookup the last value in a column and return the value of the adjacent cell

  4. 4

    Get Cell Value with column name in Php Excel

  5. 5

    Excel - Inserting cell value in formula column name

  6. 6

    Lookup cell reference of given value

  7. 7

    Refer to Excel cell in Table by header name and row number

  8. 8

    Pandas Read Excel: how to access a given cell by column and row numbers

  9. 9

    Pandas Read Excel: how to access a given cell by column and row numbers

  10. 10

    (Excel) Finding the column header associated with a cell, returning a list of names and headers

  11. 11

    Excel: If a cell = 0 then display the last entries, column header

  12. 12

    In a table with row headers and column headers, given a column header text and a cell text, how can I select a cell (td)?

  13. 13

    Excel VBA Find column name of first blank cell in row

  14. 14

    Referencing cell only by column name in Excel 2010 VBA

  15. 15

    Find out Excel column character from name of cell in first row

  16. 16

    if name appears in FILTER formula column, then lookup email addresses and combine all in one cell

  17. 17

    Find Column Header By Name And Select All Data Below Column Header (Excel-VBA)

  18. 18

    ASP VB.NET GridView: Change Column cell text by column header name with AutogenerateColumn = True

  19. 19

    Excel Find Cell Name

  20. 20

    Select the column header if cell is formula

  21. 21

    DataGridViewAutoFilter Resize Column Header Cell

  22. 22

    If cell contains value then 'Column header'

  23. 23

    Select the column header if cell is formula

  24. 24

    Using Lookup in Excel to populate column

  25. 25

    Get column header and row header on cell click

  26. 26

    Row header and column header for a particular cell in table

  27. 27

    Renaming column header in Excel

  28. 28

    Lookup last non blank cell in column excluding ""

  29. 29

    Excel VBA function to lookup value in a Cell range

HotTag

Archive