Forum Discussion
LOOKUP FORMULA BASED ON HEADERS
You could go a long way toward helping us help you by posting a copy (or a representative sample) of your spreadsheet. Your verbal description is confusing.
An actual sample of the spreadsheet itself is better than an image, and would also enable somebody here to write a formula that works and post it for you to use.
- Seaneboy2020Dec 02, 2020Copper Contributor
Thank you for your message.
I have included an example of the spreadsheet, as requested.
I am trying to populate the cells of column N, with the values in column I. I want to use the date in cell P1, as the search criteria. So any the values of any cells contained within a column, where the dates agree are shown in column N.
If you need any further information, please let me know.
Thank you.
- TwifooDec 02, 2020Silver Contributor
I suggest this formula in O2 of the attached version of your file:
=INDEX(ColumnsLeft, MATCH(Q$1,HeadersLeft,0))ColumnsLeft refers to:
=Schedule!$B2:N2HeadersLeft refers to:
=Schedule!$B$1:N$1Kindly notice these:
1. I modified the formula starting in C1 to this:
=EOMONTH(B1,1)2. I inserted a column for April 2021, with simulated values thereunder.
3. You can also insert a column for May 2021 to test the dynamic attribute of ColumnsLeft and HeadersLeft.
- Seaneboy2020Dec 02, 2020Copper ContributorThank you very much for this example.
This formula will certainly help a lot with making my spreadsheets more dynamic.
- mathetesDec 02, 2020Silver Contributor
Enter this formula in cell N2, and copy it down.
=INDEX(B2:M2,,MATCH($P$1,$B$1:$M$1,0))
To explain the formula: the MATCH function finds the column number in the array of headings that matches your date in P1 The dollar signs keep the references constant even as the total formula is copied to succeeding rows.
The INDEX function uses that number to find the corresponding column in each row as the formula is copied down to succeeding rows.
Let me know if this is in fact doing what you want. I'm curious what the actual application is here. It seems an unusual way to organize the information...so I'm wondering whether the whole spreadsheet or workbook could use a makeover. But of course, it's not my business so feel free to ignore the question.