Changing criteria range using the same cell reference based on data validation list header change

floW_5

New Member
Joined
Jan 4, 2024
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hope I got the thread title relevant to what I am about to ask,

Currently I have a table that has been filtered to only showing 3 columns of my choosing.
In G5 & H5 is the criteria range for ColumnA.
G10 & H10 is the criteria range for ColumnC.
The formula below works exactly that.

I want to take it a step further.... Cell K1 has a data validation drop down list to pick between ColumnA and ColumnB while cell L1 has a data validation drop down list between ColumnC and ColumnD.

The million dollar question is, how could I get G5 & H5 or G10 & H10 to recalculate based on which header is in K1 or L1? For example, If I choose ColumnB from the drop down list in K1, the input value from G5 & H6 (>=4 & <=75) should now look in ColumnB for the calculation and not ColumnA anymore, same goes if the drop down list in L1 is ColumnD, G10 & H10 would look in ColumnD to return the values based on G10 & H10 criteria range.

If this makes any sense, my complete gratitude in advance if anyone can help update this formula accordingly. Thank you

DataSample.xlsx
ABCDEFGHIJKL
1ColumnAColumnBColumnCColumnDCategoryCategoryColumnAColumnC
21138511451Column A or B11151
3664233571Greater or EqualLess or Equal1623
45315175411531
53999423147517553
67575534851135278
73552789871Column C or D119111
819101115641Greater or EqualLess or Equal1760
98922325242115490
10791601271
115428908541
Sheet1
Cell Formulas
RangeFormula
J2:L9J2=LET(A_,Table4[ColumnA],C_,Table4[ColumnC],Category_,Table4[Category], IFERROR(CHOOSECOLS(FILTER(Table4,ISNUMBER( 1/IF(G5,A_>=G5,Category_) *1/IF(H5,A_<=H5,Category_) *1/IF(G10,C_>=G10,Category_) *1/IF(H10,C_<=H10,Category_)) =TRUE),XMATCH(J1:L1,Table4[#Headers])),""))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
K1List=$A$1:$B$1
L1List=$C$1:$D$1
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
See if this modification to your formula does what you want.

floW_5.xlsm
ABCDEFGHIJKL
1ColumnAColumnBColumnCColumnDCategoryCategoryColumnBColumnD
21138511451Column A or B164357
3664233571Greater or EqualLess or Equal115754
4531517541175485
539994231675110564
67575534851128854
73552789871Column C or D
819101115641Greater or EqualLess or Equal
989223252421
10791601271300
115428908541
12
Sheet1
Cell Formulas
RangeFormula
J2:L6J2=LET(A_,Table4[ColumnA],B_,Table4[ColumnB],C_,Table4[ColumnC],D_,Table4[ColumnD],Category_,Table4[Category],AorB,IF(K1="ColumnA",A_,B_),CorD,IF(L1="ColumnC",C_,D_), IFERROR(CHOOSECOLS(FILTER(Table4,ISNUMBER( 1/IF(G5,AorB>=G5,Category_) *1/IF(H5,AorB<=H5,Category_) *1/IF(G10,CorD>=G10,Category_) *1/IF(H10,CorD<=H10,Category_)) =TRUE),XMATCH(J1:L1,Table4[#Headers])),""))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
K1List=$A$1:$B$1
L1List=$C$1:$D$1
 
Upvote 1
Solution
See if this modification to your formula does what you want.

floW_5.xlsm
ABCDEFGHIJKL
1ColumnAColumnBColumnCColumnDCategoryCategoryColumnBColumnD
21138511451Column A or B164357
3664233571Greater or EqualLess or Equal115754
4531517541175485
539994231675110564
67575534851128854
73552789871Column C or D
819101115641Greater or EqualLess or Equal
989223252421
10791601271300
115428908541
12
Sheet1
Cell Formulas
RangeFormula
J2:L6J2=LET(A_,Table4[ColumnA],B_,Table4[ColumnB],C_,Table4[ColumnC],D_,Table4[ColumnD],Category_,Table4[Category],AorB,IF(K1="ColumnA",A_,B_),CorD,IF(L1="ColumnC",C_,D_), IFERROR(CHOOSECOLS(FILTER(Table4,ISNUMBER( 1/IF(G5,AorB>=G5,Category_) *1/IF(H5,AorB<=H5,Category_) *1/IF(G10,CorD>=G10,Category_) *1/IF(H10,CorD<=H10,Category_)) =TRUE),XMATCH(J1:L1,Table4[#Headers])),""))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
K1List=$A$1:$B$1
L1List=$C$1:$D$1
Peter mate, Thank you so much. Formula works flawlessly, thank you!
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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