Help on putting a number into a range

tana

New Member
Joined
Jan 22, 2021
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hi,
Can someone help me with this? I am trying to put a number into corresponding range. My range table is like this:

Bonus Rating Template - Master Dummy Test a.xlsx
JK
200-84
38585-94
49595-104
5105105-114
6115115-124
7125125-134
8135135+
Input


When I put each number into the range, it seems to have problems starting at 115.

Bonus Rating Template - Master Dummy Test a.xlsx
DBDC
2200-84
3200-84
4200-84
5200-84
6200-84
7200-84
8200-84
9400-84
10400-84
11400-84
12400-84
13400-84
14600-84
15600-84
16600-84
17600-84
18600-84
19600-84
20600-84
21600-84
22600-84
23600-84
24600-84
25600-84
26600-84
27600-84
28600-84
29600-84
30750-84
31750-84
32800-84
33800-84
34800-84
35800-84
36800-84
37800-84
38800-84
39800-84
40800-84
41800-84
428585-94
438585-94
448585-94
458585-94
468585-94
478585-94
488585-94
498585-94
508585-94
518585-94
528585-94
539595-104
549595-104
559595-104
569595-104
579595-104
589595-104
599595-104
609595-104
619595-104
629595-104
639595-104
649595-104
659595-104
669595-104
679595-104
689595-104
699595-104
709595-104
719595-104
729595-104
739595-104
749595-104
759595-104
769595-104
779595-104
789595-104
799595-104
8010095-104
8110095-104
8210095-104
8310095-104
8410095-104
8510095-104
8610095-104
8710095-104
8810095-104
8910095-104
9010095-104
9110095-104
9210095-104
9310095-104
9410095-104
9510095-104
9610095-104
9710095-104
9810095-104
9910095-104
10010095-104
10110095-104
10210095-104
10310095-104
10410095-104
10510095-104
10610095-104
10710095-104
10810095-104
10910095-104
11010095-104
11110095-104
11210095-104
11310095-104
11410095-104
11510095-104
11610095-104
11710095-104
11810095-104
11910095-104
12010095-104
12110095-104
12210095-104
123105105-114
124105105-114
125105105-114
126105105-114
127105105-114
128105105-114
129105105-114
130105105-114
131110105-114
132110105-114
133110105-114
134110105-114
135110105-114
136110105-114
137110105-114
138110105-114
139110105-114
140110105-114
141110105-114
142110105-114
143110105-114
144110105-114
145110105-114
146110105-114
147110105-114
148110105-114
149110105-114
150110105-114
151110105-114
152110105-114
153110105-114
154110105-114
155110105-114
156110105-114
157110105-114
158110105-114
159110105-114
160110105-114
161110105-114
162110105-114
163115105-114
164115105-114
165115105-114
166115105-114
167115105-114
168115105-114
169115105-114
170115105-114
171115105-114
172115105-114
173115105-114
174115105-114
175115105-114
176115105-114
177115105-114
178115105-114
179115105-114
180115105-114
181115105-114
182115105-114
183115105-114
184115105-114
185115105-114
186115105-114
187115105-114
188115105-114
189115105-114
190115105-114
191115105-114
192115105-114
193115105-114
194115105-114
195115105-114
196115105-114
197115105-114
198115105-114
199115105-114
200115105-114
201115105-114
202115105-114
203115105-114
204115105-114
205115105-114
206115105-114
207115105-114
208120115-124
209120115-124
210120115-124
211120115-124
212120115-124
213120115-124
214120115-124
215120115-124
216120115-124
217120115-124
218120115-124
219120115-124
220120115-124
221120115-124
222120115-124
223120115-124
224120115-124
225120115-124
226120115-124
227120115-124
228120115-124
229120115-124
230120115-124
231120115-124
232120115-124
233120115-124
234120115-124
235120115-124
236120115-124
237120115-124
238120115-124
239120115-124
240120115-124
241120115-124
242120115-124
243120115-124
244120115-124
245130125-134
246130125-134
247135135+
248145135+
249145135+
250145135+
251145135+
252145135+
253145135+
254145135+
255145135+
256145135+
257145135+
258145135+
259145135+
260145135+
261145135+
262145135+
263145135+
264145135+
265145135+
266145135+
267145135+
268145135+
269145135+
270145135+
271145135+
272145135+
273145135+
274145135+
SortData
Cell Formulas
RangeFormula
DB2:DB274DB2=DA2#*100
DC2:DC274DC2=XLOOKUP(DB2#,Input!$J$2:$J$8,Input!$K$2:$K$8,,-1)
Dynamic array formulas.


1737946758483.png


I expected 115 is in the range of "115-124" rather than "105-114", I have tried to use vlookup as well, but same issue. Thanks!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Last thing I can suggest is to check if the a 115 in DA = Input!J6. Does it return TRUE or FALSE?
It is true.
Bonus Rating Template - Master Dummy Test.xlsx
BUBVBW
52115105-114TRUE
53115105-114TRUE
54115105-114TRUE
55115105-114TRUE
56115105-114TRUE
57115105-114TRUE
58115105-114TRUE
59115105-114TRUE
60115105-114TRUE
61115105-114TRUE
62115105-114TRUE
63115105-114TRUE
64115105-114TRUE
65115105-114TRUE
66115105-114TRUE
67115105-114TRUE
68115105-114TRUE
69115105-114TRUE
70115105-114TRUE
71115105-114TRUE
72115105-114TRUE
SortData
Cell Formulas
RangeFormula
BW52:BW72BW52=BU52=Input!$J$6


Bonus Rating Template - Master Dummy Test.xlsx
BTBUBV
20.2200-84
30.4400-84
40.6600-84
50.6600-84
60.6600-84
70.6600-84
80.6600-84
90.6600-84
100.75750-84
110.75750-84
120.8800-84
130.8800-84
140.8800-84
150.858585-94
160.858585-94
170.858585-94
180.858585-94
190.959595-104
200.959595-104
210.959595-104
22110095-104
23110095-104
24110095-104
25110095-104
26110095-104
27110095-104
28110095-104
29110095-104
30110095-104
31110095-104
32110095-104
33110095-104
34110095-104
35110095-104
36110095-104
37110095-104
38110095-104
39110095-104
401.05105105-114
411.05105105-114
421.05105105-114
431.1110105-114
441.1110105-114
451.1110105-114
461.1110105-114
471.1110105-114
481.1110105-114
491.1110105-114
501.1110105-114
511.1110105-114
521.15115105-114
531.15115105-114
541.15115105-114
551.15115105-114
561.15115105-114
571.15115105-114
581.15115105-114
591.15115105-114
601.15115105-114
611.15115105-114
621.15115105-114
631.15115105-114
641.15115105-114
651.15115105-114
661.15115105-114
671.15115105-114
681.15115105-114
691.15115105-114
701.15115105-114
711.15115105-114
721.15115105-114
731.2120115-124
741.2120115-124
751.2120115-124
761.2120115-124
771.2120115-124
781.2120115-124
791.2120115-124
801.45145135+
811.45145135+
821.45145135+
831.45145135+
841.45145135+
851.45145135+
861.45145135+
871.45145135+
881.45145135+
891.45145135+
901.2120115-124
911.45145135+
SortData
Cell Formulas
RangeFormula
BT2:BT91BT2=IF(AND('Rpt 1 H'!B4="",'Rpt 1 H'!C4="",'Rpt 1 H'!D4="",'Rpt 1 H'!E4="",'Rpt 1 H'!F4=""), I2#, IF(AND('Rpt 1 H'!B4<>"",'Rpt 1 H'!C4="",'Rpt 1 H'!D4="",'Rpt 1 H'!E4="",'Rpt 1 H'!F4=""), DROP(CHOOSECOLS(M2#,8),1), IF(AND('Rpt 1 H'!B4<>"",'Rpt 1 H'!C4<>"",'Rpt 1 H'!D4="",'Rpt 1 H'!E4="",'Rpt 1 H'!F4=""), DROP(CHOOSECOLS(Z2#,8),1), IF(AND('Rpt 1 H'!B4<>"",'Rpt 1 H'!C4<>"",'Rpt 1 H'!D4<>"",'Rpt 1 H'!E4="",'Rpt 1 H'!F4=""), DROP(CHOOSECOLS(AL2#,8),1), IF(AND('Rpt 1 H'!B4<>"",'Rpt 1 H'!C4<>"",'Rpt 1 H'!D4<>"",'Rpt 1 H'!E4<>"",'Rpt 1 H'!F4=""), DROP(CHOOSECOLS(AX2#,8),1), IF(AND('Rpt 1 H'!B4<>"",'Rpt 1 H'!C4<>"",'Rpt 1 H'!D4<>"",'Rpt 1 H'!E4<>"",'Rpt 1 H'!F4<>""), DROP(CHOOSECOLS(BJ2#,8),1), "Not Found"))))))
BU2:BU91BU2=BT2#*100
BV2:BV91BV2=VLOOKUP(BU2#,Input!J2:K8,2)
Dynamic array formulas.


Strange... what is going on here? I am super curious the truth. Sorry due to company privacy, I can't share the file. Wish you can help me to find the truth.

Appreciate for all your help so far!
 
Upvote 0
I believe that it is a floating point issue related to how Excel is feeding the DB2# spilled array into the DC2 formula.
I was already checking the same cell that @kevin999 is asking about and even when I expanded it to show 12 decimal places it showed 115.000000000000
However, trying this in DC2 returned the correct result
Excel Formula:
=VLOOKUP(ROUND(DB2#,10),Input!J2:K8,2)

So I think something to do with feeding the DB array into the formula has resulted in that 115 going in as something like 114.999999999999 & hence it was returning the 105-114 range.
 
Upvote 0
Solution
Hi,

I'm certainly no expert and over the last few weeks I have updated worksheets with LET functions. Now, getting the hang of that witchcraft is not that easy. However, this question from @tana reminded me of income tax brackets, which is the same concept. so what I did is:

* create an array where upper and lower achievement are in 2 columns and then added the bonus payout in.
* unfortunately I have not made that much progress with the witchcraft project, that I could create a complete LET function. However, I simple added an entry field for achievement E10 and a Vlookup in G10, that throws out the respective bracket.

I'm sure this can be further simplified and maybe even the raw data col J can and amended to show lower and upper limits.....

Again, just a suggestion....

Book2
ABCDEFG
100-84
28585-94
39595-104
4105105-114
5115115-124
6125125-134
7135135+
8
9
10achievement115bracket115-124
11000
120850-84
13859585-94
149510595-104
15105115105-114
16115125115-124
17125135125-134
Input
Cell Formulas
RangeFormula
G10G10=VLOOKUP(E10,E11#,3,TRUE)
E11:G17E11=LET( achieve,E10, bonusbracket, B1:B7, upper,A1:A7, lower,DROP(VSTACK(0,upper),-1), HSTACK(lower, upper, DROP(VSTACK(0,bonusbracket),-1)) )
Dynamic array formulas.
 
Upvote 0
So I think something to do with feeding the DB array into the formula has resulted in that 115 going in as something like 114.999999999999
Actually, that may not be quite right since if I click on DC2 and invoke the 'Evaluate Formula' tool, Evaluate one step then scroll through the values they still appear as 115, so it may be more an issue of how the VLOOKUP actually processes the array of values. Either way, it appears to be a rounding/floating point issue and would need to be handled with some form of rounding as suggested earlier to assure correct results.
 
Upvote 0
may be more an issue of how the VLOOKUP actually processes the array of values.
Wrong again. It has nothing to do with the fact that VLOOKUP is being fed an array of values, it is something (I don't know what) about how the value of 1.15*100 is stored and/or retrieved by Excel. Take these three individual VLOOKUPs. In each case the VLOOKUP is looking up 115 but the 115 has been calculated different ways and it is just that particular calculation of 115 that seems to be the issue. Note that the issue also arises if we use XLOOKUP or LOOKUP instead of VLOOKUP as well.

tana.xlsm
JKLMNOPQ
1VLOOKUPXLOOKUPLOOKUP
200-841.15115.000000000000000000000000000000105-114105-114105-114
38585-94115115.000000000000000000000000000000115-124115-124115-124
49595-10423115.000000000000000000000000000000115-124115-124115-124
5105105-114
6115115-124
7125125-134
8135135+
Input
Cell Formulas
RangeFormula
N2N2=100*M2
O2:O4O2=VLOOKUP(N2,J$2:K$8,2)
P2:P4P2=XLOOKUP(N2,J$2:J$8,K$2:K$8,,-1)
Q2:Q4Q2=LOOKUP(N2,J$2:J$8,K$2:K$8)
N3N3=1*M3
N4N4=5*M4


@Holger
If you put the formula =1.15*100 in your yellow cell you will see the same result as well. :cool:

tana.xlsm
DEFG
10achievement115bracket105-114
11000
120850-84
13859585-94
149510595-104
15105115105-114
16115125115-124
17125135125-134
Sheet1
Cell Formulas
RangeFormula
G10G10=VLOOKUP(E10,E11#,3,TRUE)
E10E10=1.15*100
E11:G17E11=LET( achieve,E10, bonusbracket, B1:B7, upper,A1:A7, lower,DROP(VSTACK(0,upper),-1), HSTACK(lower, upper, DROP(VSTACK(0,bonusbracket),-1)) )
Dynamic array formulas.
 
Upvote 0
@Peter_SSs does this suggest that if the input cell is a formula the search through an array works different as to a plain number?
No, if you did what I suggested in your yellow cell and now get the wrong answer, try this.
Select that yellow cell with the formula, Copy it and use Paste Special (Values) to put the value back in the same yellow cell where the formula was.
The cell now contains a number, not a formula, but the result is still incorrect.

It is about how Excel, running on a machine, does not and cannot always do everything exactly as a human would do. See here for some further reading.
Also look at (& try for yourself) the 3 calculations shown in this post that all give exactly the same result if I do them manually myself, but not when Excel does them. :eek:
 
Upvote 0
Looks like a floating decimal issue.
Book1
JKLMNOPQR
1VLOOKUPXLOOKUPLOOKUPMOD
200-841.15115105-114105-114105-1140.99999999999998600
38585-94115115115-124115-124115-1240.00000000000000000
49595-10423115115-124115-124115-1240.00000000000000000
5105105-114
6115115-124
7125125-134
8135135+
Input
Cell Formulas
RangeFormula
N2N2=100*M2
O2:O4O2=VLOOKUP(N2,J$2:K$8,2)
P2:P4P2=XLOOKUP(N2,J$2:J$8,K$2:K$8,,-1)
Q2:Q4Q2=LOOKUP(N2,J$2:J$8,K$2:K$8)
R2:R4R2=MOD(N2:N4,1)
N3N3=1*M3
N4N4=5*M4
Dynamic array formulas.
 
Upvote 0
Further investigation reveals that, it's not unique to 1.15.
It occurs for some decimals that cannot be precisely represented in binary. Another example is 1.1.When multiplying 1.15 x 100, it magnifies the error. It just happens that the floating point error for 1.15 x100 is too close to 1.
Book1
JKLMNOPQR
1VLOOKUPXLOOKUPLOOKUPMOD
200-841.15115105-114105-114105-1140.99999999999998600
38585-94115115115-124115-124115-1240.00000000000000000
49595-10423115115-124115-124115-1240.00000000000000000
5110105-1141.1110105-114105-114105-1140.00000000000001421
6115115-124
7125125-134
8135135+
Input
Cell Formulas
RangeFormula
N2,N5N2=100*M2
O2:O5O2=VLOOKUP(N2,J$2:K$8,2)
P2:P5P2=XLOOKUP(N2,J$2:J$8,K$2:K$8,,-1)
Q2:Q5Q2=LOOKUP(N2,J$2:J$8,K$2:K$8)
R2:R5R2=MOD(N2:N5,1)
N3N3=1*M3
N4N4=5*M4
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,226,049
Messages
6,188,567
Members
453,484
Latest member
jlo1673

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