+ Reply to Thread
Results 1 to 4 of 4

vba if statements based on weight and fee calculation

  1. #1
    Registered User
    Join Date
    11-07-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    14

    vba if statements based on weight and fee calculation

    Hi,
    I am trying to find out how i can set up if statements based on parameter values. For example;

    My function will be "Shippingfees" based on the parameter weight

    Shipping fee is calculated based on weight.
    If it is 1 pound, shipping fee is $2
    If it is 2 pounds, shipping fee is $4
    After two pounds, fee is increasing by $1 for every pound. But if the weight is 2.3 pounds this will still be based on 3 pounds. So it actually means if weight>2 and weight<=3 fee will add up one more dollar.
    If it is , let 's say 5.3 pounds, then the fee will be 8 dollars ($4 + $1 + $1 + $1 + $1) [because it will be recognized as 6 pounds]

    My question is how can i set up this in vba?
    I'd very much appreciate if anyone could help.
    Thanks

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: vba if statements based on weight and fee calculation

    Why not just set up a table of weights in whole numbers in column A on Sheet2. In column B, put in the cost of the shipping weight.

    In your spreadsheet where you have the actual weights (Assume Column A), in a column next to it, type =vlookup(A1,Sheet2!$A$1:$B$100,2,true) and then copy down.

    See attached example
    Attached Files Attached Files
    Last edited by alansidman; 09-22-2013 at 09:33 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    11-07-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: vba if statements based on weight and fee calculation

    Hi,
    Thanks for your reply. But i will be expanding it creting other functions and conditions. The fee calculations are a small part of this and I will be using too many if statements embedded in these fee calcualtions. The size of the file will be huge slowing down the processing if i use only excel . I'd be better off setting this up in vba which will make it a lot faster. Thank you

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: vba if statements based on weight and fee calculation

    In that case, suggest a case select function.

    Look here: http://www.techonthenet.com/excel/formulas/case.php

    I think three case statements
    1. Weight is less than 2#; $2
    2. Weight is between 2# and 3#; $4
    3. Weight is greater than or equal to 3#; Calculated $Value
    Last edited by alansidman; 09-22-2013 at 10:20 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto Calculate Shipping Weight/Cartons and Package Weight.
    By suhailsiddiqui09 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2013, 06:48 AM
  2. PLZ HELP ME ON!!! Surcharge calculation based on weight ...
    By bukhari9 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-07-2013, 11:49 AM
  3. Weight calculation
    By artonwood in forum Excel General
    Replies: 9
    Last Post: 10-18-2009, 01:40 PM
  4. Cost of Carriage based on Volumetric Weight
    By raylogic in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-16-2007, 03:26 PM
  5. Have Excel enter various values based on weight
    By marknorton in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2007, 08:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1