Dynamic Index/Match and HLookup Query Based on Column Headers

emmarahudson

New Member
Joined
Mar 19, 2014
Messages
23
Hello Everybody

Please see below a scaled down version of a report I'm working on. What I want to do is write a formula in columns B and C which will pull through the values in columns G and J (respectively). So, B3 = 0, B4 = 7, B5 = 9, B6 = 15 (and so on for columns C/I).

I have written a very basic Index/Match using the column headers but I'm now a bit lost. I think I may need to use HLookup as well but I'm not sure how to incorporate it. Can anybody help me?


Excel 2010
ABCDEFGHIJ
1Sales Inc FOCPurchasesSalesSalesSales Inc FOCPurchasesPurchasesPurchases
2OverallOverallJanFebOverallJanFebOverall
3Alpha0000123
4Beta0347112
5Gamma0729000
6Delta069157411
Sheet1
Cell Formulas
RangeFormula
B3=INDEX($E$1:$J$6,MATCH($B$1,$E$1:$J$1,0),MATCH($B$2,$E$2:$J$2,0))
B4=INDEX($E$1:$J$6,MATCH($B$1,$E$1:$J$1,0),MATCH($B$2,$E$2:$J$2,0))
B5=INDEX($E$1:$J$6,MATCH($B$1,$E$1:$J$1,0),MATCH($B$2,$E$2:$J$2,0))
B6=INDEX($E$1:$J$6,MATCH($B$1,$E$1:$J$1,0),MATCH($B$2,$E$2:$J$2,0))
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Excel 2010
ABCDEFGHIJ
1Sales Inc FOCPurchasesSalesSalesSales Inc FOCPurchasesPurchasesPurchases
2OverallOverallJanFebOverallJanFebOverall
3Alpha03000123
4Beta72347112
5Gamma90729000
6Delta151169157411
Sheet2
Cell Formulas
RangeFormula
B3{=INDEX($E3:$J3,MATCH(B$1&B$2,$E$1:$J$1&$E$2:$J$2,0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thank you so much. I was trying a similar array formula earlier but I'd indexed the wrong cells! Thank you so much, you've just cut my Saturday afternoon work in half.
 
Upvote 0
Hi Sheetspread

I have another query which is sort of related to the one you helped me with on Saturday.

I've got a large amount of data on a tab titled 'Data' (surprise surprise!). I've cut it down to the parts that are relevant (see below).


Excel 2010
HADAEAFAGAHAI
1ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016
2JAN 2016FEB 2016MAR 2016APR 2016MAY 2016Overall Result
3Material
4M20066100
5M20084100
6M20101113076.8413076.84
7M20101111999.9211999.92
8M20101112499.9112499.91
9M201011000
10M20101100
11M20101111223.2200.01011813.91526
Data



On another tab titled 'Summary' I am trying to find the lowest selling price within the above set of data for each product (excluding zero values). The product list in the 'Summary' tab is located in column C. To find the lowest value for each product, I have written an array formula but I've had to specify the column which it is to look in. What I'd like to do, is replace the "IF(Data!AA:AA>0,Data!AA:AA)" part of the formula with something that uses the headers in rows 1 and 2 of the 'Data' tab. The reason I need to use the header titles instead of specifying the column is the data moves every month as I add more to the spreadsheet. I know that I could just paste the data I need into another tab, but I'd really like to avoid this if possible because it creates more work.


Excel 2010
CCVCWCXCYCZDADBDCDDDEDFDG
11LSPLSPLSPLSPLSPLSPLSPLSPLSPLSPLSPLSP
12MaterialJan-16Feb-16Mar-16Apr-16May-16Jun-16Jul-16Aug-16Sep-16Oct-16Nov-16Dec-16
396M20101141999.7670883.52149.3512499.9111223.2212499.910.0111813.9211813.92
Summary
Cell Formulas
RangeFormula
CV396{=IFERROR(IF(MIN(IF(Data!$H:$H=Summary!$C396,IF(Data!AA:AA>0,Data!AA:AA)))=0,"",MIN(IF(Data!$H:$H=Summary!$C396,IF(Data!AA:AA>0,Data!AA:AA)))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Try this
ARRAY formula in CV396, then dragged across
Code:
=IFERROR(SMALL(IF((data!$H$4:$H$11=$C396)*(INDEX(data!$AD$4:$AI$11,,MATCH(CV$12,data!$AD$2:$AI$2,0))>0),INDEX(data!$AD$4:$AI$11,,MATCH(CV$12,data!$AD$2:$AI$2,0)),""),1),"")
 
Last edited:
Upvote 0

Excel 2010
HADAEAFAGAHAI
2Jan-16Feb-16Mar-16Apr-16May-16Overall Result
3Material
4M20066100
5M20084100
6M20101113076.8413076.84
7M20101111999.9211999.92
8M20101112499.9112499.91
9M201011000
10M20101141999.7600
11M20101111223.2200.01011813.91526
Data



Excel 2010
CCVCWCXCYCZDADBDCDDDEDFDG
11LSPLSPLSPLSPLSPLSPLSPLSPLSPLSPLSPLSP
12Material1-Jan1-Feb1-Mar1-Apr1-May1-Jun1-Jul1-Aug1-Sep1-Oct1-Nov1-Dec
396M20101141999.7611223.2212499.910.0113076.84
Summary
Cell Formulas
RangeFormula
CV396{=MIN(IF(Data!$H$4:$H$11=$C396,IF(INDEX(Data!$AD$4:$AH$11,,MATCH(CV$12,Data!$AD$2:$AH$2,0))<>0,INDEX(Data!$AD$4:$AH$11,,MATCH(CV$12,Data!$AD$2:$AH$2,0)))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


works too
 
Upvote 0
Hiya, thanks for coming back to me, it's really appreciated. The problem I'm having is that I need the 'MATCH(CV$12,Data!$AD$2:$AH$2,0)' part of the formula to look at rows 1 and 2. The data I am working with has lots of different headers in row 1 (the table I pasted into the forum is scaled down). So, if I use January as an example, I'd like the formula to return the lowest value if row 1 contains "ASP w/o FOC" and if row 2 contains "JAN 2016". At the moment, the formula is just looking at the date in row 2. Is that something that can be done? I've played around with it myself and I get certain parts of it to function, but I just can't seem to bring it all together.
 
Upvote 0
Something like this?


Excel 2010
CCVCWCXCYCZDADBDCDDDEDFDG
11ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016ASP w/o FOC JAN 2016 - MAY 2016LSPLSPLSPLSPLSPLSPLSPLSP
12Material1-Jan1-Feb1-Mar1-Apr1-May1-Jun1-Jul1-Aug1-Sep1-Oct1-Nov1-Dec
396M20101141999.7611223.2212499.910.01
Summary
Cell Formulas
RangeFormula
CV396{=MIN(IF(Data!$H$4:$H$11=$C396,IF(INDEX(Data!$AD$4:$AH$11,,MATCH(CV$11&CV$12,Data!$AD$1:$AH$1&Data!$AD$2:$AH$2,0))<>0,INDEX(Data!$AD$4:$AH$11,,MATCH(CV$11&CV$12,Data!$AD$1:$AH$1&Data!$AD$2:$AH$2,0)))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hiya, thanks for coming back to me. I've just managed to sort it. Solution below in case anyone else ever needs to resolve a query like this. Thank you so much for all your help, Sheetspread :)

=IFERROR(SMALL(IF((Data!$H$4:$H$10000=$C396)*(INDEX(Data!$AD$4:$XFD$10000,,MATCH("*ASP*"&CV$12,Data!$AD$1:$XFD$1&Data!$AD$2:$XFD$2,0))<>0),INDEX(Data!$AD$4:$XFD$10000,,MATCH("*ASP*"&CV$12,Data!$AD$1:$XFD$1&Data!$AD$2:$XFD$2,0)),""),1),"")
 
Upvote 0

Forum statistics

Threads
1,216,129
Messages
6,129,055
Members
449,484
Latest member
khairianr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top