Determine if a value falls within a range and return a corresponding value

cvrband

Board Regular
Joined
Jan 6, 2016
Messages
63
Office Version
  1. 365
Platform
  1. Windows
Below is an example spreadsheet showing what I'm trying to accomplish. In words, using a spilling type formula (because my spreadsheet is dynamic) I would like to determine if each value in the 'Items' list falls within a range in a table named 'Grouping'. If so, it will return the 'Group #' associated with the range that the 'Items' value fell within starting in cell C5. If the value doesn't fall within any of the ranges like AA1, 5, or BB in this example, the formula returns something that is not in the 'Group #' list like a "", -, or 0 value. Note that the grouping table may not have breaks in it as I show, so group #1 could be 1 - 5, group #2 be 6 - 9, etc.

Thank you in advance for your help writing a formula that can accomplish this task.

Book1
ABCDEFG
1
2
3DesiredGrouping
4ItemsResultGroup #BeginEnd
5AA114
6AA1269
71131112
821
931
1041
115
1262
1372
1482
1592
1610
17113
18123
19BB
Sheet1
Cell Formulas
RangeFormula
E5:E7E5=SEQUENCE(COUNTA(Grouping[Begin]))
Dynamic array formulas.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:

Dante Amor
ABCDEFG
1
2
3DesiredGrouping
4ItemsResultGroup #BeginEnd
5AA114
6AA1269
71131112
821
931
1041
115 
1262
1372
1482
1592
1610 
17113
18123
19BB
Dante Amor
Cell Formulas
RangeFormula
C7:C18C7=IFERROR(INDEX($E$5:$E$7,SUMPRODUCT(($F$5:$F$7<=A7)*($G$5:$G$7>=A7)*ROW($E$5:$E$7))-ROW($E$5)+1),"")


Or this:

Dante Amor
ABCDEFG
1
2
3DesiredGrouping
4ItemsResultGroup #BeginEnd
5AA114
6AA1269
71131112
821
931
1041
115 
1262
1372
1482
1592
1610 
17113
18123
19BB
Dante Amor
Cell Formulas
RangeFormula
C7:C18C7=IFERROR(INDEX($E$5:$E$7,LOOKUP(2,1/(($F$5:$F$7<=A7)*($G$5:$G$7>=A7)),ROW($E$5:$E$7))-ROW($E$5)+1),"")
 
Last edited:
Upvote 0
Thank you for your reply, DanteAmor. The formulas you provide appear to work for the example given (specifically the first formula) but if I add/expand the 'Items' list with more numerical values or add more begin/end values to the 'Grouping' table, the formula ranges aren't correct anymore and will need to be manually updated. I'm finding that the F & G column references update when adding more begin/end values (I think because it is expanding the table and Excel recognizes that) but the references to ranges in the E column don't expand as more begin/end values are added. Notice in my example that the E column range expands automatically every time a new begin value is added to the table due to the formula I have in E5. Because of that, I was hoping the range could be auto-expanded with a reference to E5# but I may be way off base. I appreciate your help.
 
Upvote 0
You can create a table on columns e, f and g. in the formula you change the ranges by the references to the table. or try the following

Excel Formula:
=SUMIFS(E:E,F:F,"<=" & A7,G:G,">=" & A7)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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