Need a formula to compare one cell to a range, then depending on the result multiply to another cell

katryte623

New Member
Joined
May 30, 2018
Messages
5
I'm going to explain this as easy as I possibly can. Cell Z4 has a fuel amount. Let's say $2.50. If that amount falls within this range, then it will multiply by that percentage. So if somebody where to change the number in Z4, the result would update. The result is going in cell Z10.

Now once the fuel surcharge is calculated, I also need the fuel calculated which is a simple Y10*1.65.

So my original calculation was:
=IF(AND(Z4>=A42,Z4<B42),Z4*D42,IF(AND(Z4>=A43,Z4<B43),Z4*D43,IF(AND(Z4>=A44,Z4<B44),Z4*D44,IF(AND(Z4>=A45,Z4<B45),Z4*D45,IF(AND(Z4>=A46,Z4<B46),Z4*D46)*IF(AND(Z4>=A47,Z4<B47),Z4*D47,IF(AND(Z4>=A48,Z4<B48),Z4*D48,IF(AND(Z4>=A49,Z4<B49),Z4*D49,IF(AND(Z4>=A50,Z4<B50),Z4*D50,IF(AND(Z4>=A51,Z4<B51),Z4*D51,IF(AND(Z4>=A52,Z4<B52),Z4*D52,IF(AND(Z4>=A53,Z4<B53),Z4*D53,IF(AND(Z4>=A54,Z4<B54),Z4*D54,IF(AND(Z4>=A55,Z4<B55),Z4*D55)))))))))))))+(X10*1.65)

but that did not work


column A column B column D
row 42 $2.60 $2.69 1%
row 43 $2.70 $2.79 2%
row 44 $2.80 $2.89 3%
row 45 $2.90 $2.99 4%
row 46 $3.00 $3.09 5%
row 47 $3.10 $3.19 6%
row 48 $3.20 $3.29 7%
row 49 $3.30 $3.39 8%
row 50 $3.40 $3.49 9%
row 51 $3.50 $3.59 10%
row 52 $3.60 $3.69 11%
row 53 $3.70 $3.79 12%
row 54 $3.80 $3.89 13%
row 55 $3.90 $3.99 14%

Thank you!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

katryte623

New Member
Joined
May 30, 2018
Messages
5
The formula did not copy correctly, its actually this but a longer continuance =IF(AND(Z4>=A42,Z4<B42),Z4*D42,IF(AND(Z4>=A43,Z4<B43),Z4*D43
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Hi,

Put an EXTRA SPACE in front of ALL the "less than" < symbols in your formula so it'll show properly.
 

katryte623

New Member
Joined
May 30, 2018
Messages
5
ok so I tried a different, shorter way:

=($X$10*((SUMPRODUCT(($Z$4>=$A42:$A55)*($Z$4<=$B42:$B55)*$Z$4*($D42:$D55)))))

(the formula looks right to me, I hope when I post all of the symbols don't go away)
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
That's what I "thought" you were trying to do, below is "slightly" cleaned upped version of your SUMPRODUCT formula, and a LOOKUP alternative.
I don't think you were on the right tract with the Original IF/AND statement (although IF/AND could work, but I think the logic was not correct in your attempt).

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>X</th><th>Y</th><th>Z</th><th>AA</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">$3.00 </td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">99</td><td style="text-align: right;;"></td><td style="text-align: right;;">$14.85 </td><td style="text-align: right;;">$14.85 </td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">41</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">42</td><td style="text-align: right;;">$2.60 </td><td style="text-align: right;;">$2.69 </td><td style="text-align: right;;"></td><td style="text-align: right;;">1%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">43</td><td style="text-align: right;;">$2.70 </td><td style="text-align: right;;">$2.79 </td><td style="text-align: right;;"></td><td style="text-align: right;;">2%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">44</td><td style="text-align: right;;">$2.80 </td><td style="text-align: right;;">$2.89 </td><td style="text-align: right;;"></td><td style="text-align: right;;">3%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">45</td><td style="text-align: right;;">$2.90 </td><td style="text-align: right;;">$2.99 </td><td style="text-align: right;;"></td><td style="text-align: right;;">4%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">46</td><td style="text-align: right;;">$3.00 </td><td style="text-align: right;;">$3.09 </td><td style="text-align: right;;"></td><td style="text-align: right;;">5%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">47</td><td style="text-align: right;;">$3.10 </td><td style="text-align: right;;">$3.19 </td><td style="text-align: right;;"></td><td style="text-align: right;;">6%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">48</td><td style="text-align: right;;">$3.20 </td><td style="text-align: right;;">$3.29 </td><td style="text-align: right;;"></td><td style="text-align: right;;">7%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">49</td><td style="text-align: right;;">$3.30 </td><td style="text-align: right;;">$3.39 </td><td style="text-align: right;;"></td><td style="text-align: right;;">8%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">50</td><td style="text-align: right;;">$3.40 </td><td style="text-align: right;;">$3.49 </td><td style="text-align: right;;"></td><td style="text-align: right;;">9%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">51</td><td style="text-align: right;;">$3.50 </td><td style="text-align: right;;">$3.59 </td><td style="text-align: right;;"></td><td style="text-align: right;;">10%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">52</td><td style="text-align: right;;">$3.60 </td><td style="text-align: right;;">$3.69 </td><td style="text-align: right;;"></td><td style="text-align: right;;">11%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">53</td><td style="text-align: right;;">$3.70 </td><td style="text-align: right;;">$3.79 </td><td style="text-align: right;;"></td><td style="text-align: right;;">12%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">54</td><td style="text-align: right;;">$3.80 </td><td style="text-align: right;;">$3.89 </td><td style="text-align: right;;"></td><td style="text-align: right;;">13%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">55</td><td style="text-align: right;;">$3.90 </td><td style="text-align: right;;">$3.99 </td><td style="text-align: right;;"></td><td style="text-align: right;;">14%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:5.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet64</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Z10</th><td style="text-align:left">=$X$10*SUMPRODUCT(<font color="Blue">(<font color="Red">$Z$4>=$A42:$A55</font>)*(<font color="Red">$Z$4<=$B42:$B55</font>)*$Z$4*(<font color="Red">$D42:$D55</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">AA10</th><td style="text-align:left">=$X$10*LOOKUP(<font color="Blue">$Z$4,$A42:$A55,$D42:$D55</font>)*$Z$4</td></tr></tbody></table></td></tr></table><br />
 

katryte623

New Member
Joined
May 30, 2018
Messages
5
I see how you cleaned up the formula! Thanks! So I tried it and in my X10 I have 125 and in Z4 I have $3.307. So when I enter the formula in, the result that pops up is $33.07. But if you simply take 125 x 8% (since $3.307 falls into the 8% category - line 49) the result is $10.00
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Then why do you have *Z4 in your formula in Post #4 ???

If all you want is X10 ( 125 ) * 8%, just take out *Z4 in the formulas:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>X</th><th>Y</th><th>Z</th><th>AA</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">$3.307 </td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">125</td><td style="text-align: right;;"></td><td style="text-align: right;;">$10.00 </td><td style="text-align: right;;">$10.00 </td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">41</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">42</td><td style="text-align: right;;">$2.60 </td><td style="text-align: right;;">$2.69 </td><td style="text-align: right;;"></td><td style="text-align: right;;">1%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">43</td><td style="text-align: right;;">$2.70 </td><td style="text-align: right;;">$2.79 </td><td style="text-align: right;;"></td><td style="text-align: right;;">2%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">44</td><td style="text-align: right;;">$2.80 </td><td style="text-align: right;;">$2.89 </td><td style="text-align: right;;"></td><td style="text-align: right;;">3%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">45</td><td style="text-align: right;;">$2.90 </td><td style="text-align: right;;">$2.99 </td><td style="text-align: right;;"></td><td style="text-align: right;;">4%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">46</td><td style="text-align: right;;">$3.00 </td><td style="text-align: right;;">$3.09 </td><td style="text-align: right;;"></td><td style="text-align: right;;">5%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">47</td><td style="text-align: right;;">$3.10 </td><td style="text-align: right;;">$3.19 </td><td style="text-align: right;;"></td><td style="text-align: right;;">6%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">48</td><td style="text-align: right;;">$3.20 </td><td style="text-align: right;;">$3.29 </td><td style="text-align: right;;"></td><td style="text-align: right;;">7%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">49</td><td style="text-align: right;;">$3.30 </td><td style="text-align: right;;">$3.39 </td><td style="text-align: right;;"></td><td style="text-align: right;;">8%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">50</td><td style="text-align: right;;">$3.40 </td><td style="text-align: right;;">$3.49 </td><td style="text-align: right;;"></td><td style="text-align: right;;">9%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">51</td><td style="text-align: right;;">$3.50 </td><td style="text-align: right;;">$3.59 </td><td style="text-align: right;;"></td><td style="text-align: right;;">10%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">52</td><td style="text-align: right;;">$3.60 </td><td style="text-align: right;;">$3.69 </td><td style="text-align: right;;"></td><td style="text-align: right;;">11%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">53</td><td style="text-align: right;;">$3.70 </td><td style="text-align: right;;">$3.79 </td><td style="text-align: right;;"></td><td style="text-align: right;;">12%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">54</td><td style="text-align: right;;">$3.80 </td><td style="text-align: right;;">$3.89 </td><td style="text-align: right;;"></td><td style="text-align: right;;">13%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">55</td><td style="text-align: right;;">$3.90 </td><td style="text-align: right;;">$3.99 </td><td style="text-align: right;;"></td><td style="text-align: right;;">14%</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:5.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet64</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Z10</th><td style="text-align:left">=$X$10*SUMPRODUCT(<font color="Blue">(<font color="Red">$Z$4>=$A42:$A55</font>)*(<font color="Red">$Z$4<=$B42:$B55</font>)*(<font color="Red">$D42:$D55</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">AA10</th><td style="text-align:left">=$X$10*LOOKUP(<font color="Blue">$Z$4,$A42:$A55,$D42:$D55</font>)</td></tr></tbody></table></td></tr></table><br />
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
You're welcome, welcome to the forum.

No problem at All, glad to help.
 

Watch MrExcel Video

Forum statistics

Threads
1,090,388
Messages
5,414,158
Members
403,515
Latest member
see_mido

This Week's Hot Topics

Top