简体   繁体   中英

In Excel, "if greater than 0 and less then 10 then "x", but if greater then 10 and less then 20 then "y" in same cell

I am trying to create a formula to calculate shipping based on price but I have only been able to find this:

=IF(AND(D2>0.01,D2<13.51),4.51,"")

Basically it reads "If the total purchase (D2) is greater then $0.01 and less then $13.51 apply $4.51 as the shipping fee. This works for the one fee but I need it to apply the other fees as well and I cannot seem to figure out how to do multiple greater than, less than in one formula.

So I need to be able to add multiple of that same code and change the numbers, but I can't figure out how to do multiple without getting an error.

VLOOKUP with approximate match sounds like it would be the easiest if you have a lot of shipping prices. The lookup table is in grey and you can setup however you like. If column 'B', put the formula =VLOOKUP(A2,$D$2:$E$5,2,TRUE) The TRUE is was provides the approximate match.

A nested IF would work, but would be horrible to manage. Using the VLOOKUP, anyone could maintain the lookup table.

示例图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM