VLOOKUP calculate shipping cost (2024)

This example shows how to use the VLOOKUP function to calculate the total shipping cost for an item in one formula, where the cost per kilogram (kg) varies according to weight.This requires an "approximate match" since in most cases the actual weight will not appear in the shipping cost table. For convenience, the range E5:F9 isnamed cost_table. This is an "approximate-match" lookup problem because it is not likely that a given weight will be found in the cost table. As a result, the formula needs to match the largest weight in the table that is less than or equal to the given weight. Finally, the result of the lookup operation should multiply thecost per kilogram returned by VLOOKUP by the weight in column B to get a final cost.

VLOOKUP function

VLOOKUP is an Excel function to get data from a table organized vertically. Lookup values must appear in the first column of the table provided to VLOOKUP, and the information to retrieve is specified by column number. If you are new to VLOOKUP, see:

VLOOKUP solution

In the worksheet shown, the formula in cell C5 is:

=VLOOKUP(B5,cost_table,2,TRUE)*B5

where cost_table (E5:F9) is anamed range.VLOOKUP requires lookup values to be in the first column of the lookup table. To retrieve the correct cost per kilogram for a given weight,VLOOKUP is configured like this:

  • The lookup_value comes from cell B5
  • The table_arrayis the named range cost_table (E5:F9)
  • The col_index_num is 2 since the cost appearsin the second column of the table
  • The range_lookup argument is set to TRUE = approximate match

With a score provided as a lookup value, VLOOKUP will scan the first column of the table. If it finds an exact match, it will return the cost in that row. If VLOOKUP does not find an exact match, it will continue scanning until it finds a value greater than the lookup value, then it will "step back", and return the cost in the previous row. As the formula is copied down column C, the VLOOKUP function looks up each weight in column B and returns the correct cost per kilogram (kg). Finally, the result from VLOOKUP is multiplied by the original weight in column B to get a total shipping cost.

Notes: (1) In approximate match mode, VLOOKUP assumes the table is sorted by the values in the first column. This means the cost table must be sorted in ascending order by weight. (2) As an alternative, you could add a helper column that contains only the VLOOKUP part of the formula to calculate the cost per kilogram, then perform the multiplication separately.

Named range optional

The named range in this example is optional and used for convenience only because it makes the formula easier to read and means that the cost table does not need to be locked when the formula is copied down column C.To avoid using a named range, use an absolute reference like this:

=VLOOKUP(B5,$E$5:$F$9,2,TRUE)*B5

VLOOKUP match modes

VLOOKUP has two match modes: exact match and approximate match, controlled by an optional fourth argument called range_lookup. When range_lookup is omitted, it defaults to TRUE and VLOOKUP performs an approximate match. This means we could leave out the range_lookup and get the same result with this formula:

=VLOOKUP(B5,cost_table,2)*B5

However, I recommend that you always provide a value for range_lookup because it makes you consider the behavior you want. In other words, givinga value for range_lookup acts as a reminder to you and others of the intended behavior.

Notes: If the weight is less than the first entry in the table, VLOOKUP will return the #N/A error. In the example shown, we use zero in cell E5 to make sure this does not occur.

Adding a minimum cost

To modify the formula to return a minimum cost of $15, regardless of weight, you cannest the original formula inside the MAX function like so:

=MAX(VLOOKUP(B5,cost_table,2,TRUE)*B5,15)

After the original formula runs and returns a calculated total cost, the MAX function will return whichever is greater - the result of the formula or 15.

VLOOKUP calculate shipping cost (2024)
Top Articles
4 Types of AI: Getting to Know Artificial Intelligence
Who Owns McDonalds?
Po Box 7250 Sioux Falls Sd
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Tesla Supercharger La Crosse Photos
Kokichi's Day At The Zoo
Kansas Craigslist Free Stuff
Shorthand: The Write Way to Speed Up Communication
Obituary (Binghamton Press & Sun-Bulletin): Tully Area Historical Society
Best Theia Builds (Talent | Skill Order | Pairing + Pets) In Call of Dragons - AllClash
Acbl Homeport
123 Movies Babylon
Mercy MyPay (Online Pay Stubs) / mercy-mypay-online-pay-stubs.pdf / PDF4PRO
Springfield Mo Craiglist
Love In The Air Ep 9 Eng Sub Dailymotion
Midlife Crisis F95Zone
065106619
Craftology East Peoria Il
Eva Mastromatteo Erie Pa
Palm Coast Permits Online
Bj Alex Mangabuddy
Best Nail Salons Open Near Me
What Is The Lineup For Nascar Race Today
Jordan Poyer Wiki
Prot Pally Wrath Pre Patch
Walmart Pharmacy Near Me Open
Beaufort 72 Hour
Bleacher Report Philadelphia Flyers
4Oxfun
JVID Rina sauce set1
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Ou Football Brainiacs
Miles City Montana Craigslist
Hrconnect Kp Login
Angel Haynes Dropbox
Publix Christmas Dinner 2022
Mini-Mental State Examination (MMSE) – Strokengine
Motor Mounts
Kamzz Llc
4083519708
Second Chance Apartments, 2nd Chance Apartments Locators for Bad Credit
Kutty Movie Net
6576771660
30 Years Of Adonis Eng Sub
Port Huron Newspaper
Devotion Showtimes Near Showplace Icon At Valley Fair
Headlining Hip Hopper Crossword Clue
552 Bus Schedule To Atlantic City
Germany’s intensely private and immensely wealthy Reimann family
Roller Znen ZN50QT-E
Sam's Club Fountain Valley Gas Prices
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 6163

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.