+ Reply to Thread
Results 1 to 8 of 8

Macro or Formula to calculate different price thresholds?

  1. #1
    Registered User
    Join Date
    01-05-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro or Formula to calculate different price thresholds?

    Hello everybody,

    I want to calculate a formula based on the increment of a value in a cell. For example, I want to calculate the weight based on $25 for the first Kg and 15$ for every subsequent Kg. I can write a formula for that, but it takes for only 1 Kg increments and not for decimals like 1.5 Kg or 1.2 Kg...etc. Any help would be appreciated.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    Re: Macro or Formula?

    Your question is not clear. I do not think you have supplied all the necessary info or that it is even an Excel question. Are the weight increments always in 1/10ths of a KG? If each additional KG is $15, does each additional 1/10th KG cost $1.50?

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Macro or Formula?

    Formula always before even thinking Macro.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Macro or Formula?

    Hello, assuming B1 = 25 and B2 = 15 for the prices, weight is entered in B3, then price can be calculated with

    =IF(B3>1,(B3-1)*B2+B1,B3*B1)

    The same principle can be applied to other thresholds. Can you post an example of what you really want to calculate?
    Last edited by teylyn; 01-05-2011 at 10:23 PM.

  5. #5
    Registered User
    Join Date
    01-05-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro or Formula?

    Hi Connor and Teylyn. This is what I want to achieve;
    For the first Kg, it is $25. Each subsequent Kg after that is $15. Say if it is 2 Kgs, it is $25+$15=$40, 3 Kgs it is $25+$15+$15=$55...etc. I have created a formula for that as
    IF(A2<=1,25,((A2*15)-15)+25) where A2 is the cell I am entering the weight. Yes, each additional 1/10th Kg will cost $1.50.

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Macro or Formula?

    Does that mean that the price for 0.5 kg is also $25? So, everything up to the first full KG is $25?

    If so, your formula is correct.

    What is the question?

  7. #7
    Registered User
    Join Date
    01-05-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro or Formula?

    Quote Originally Posted by Conor View Post
    Your question is not clear. I do not think you have supplied all the necessary info or that it is even an Excel question. Are the weight increments always in 1/10ths of a KG? If each additional KG is $15, does each additional 1/10th KG cost $1.50?
    Quote Originally Posted by teylyn View Post
    Hello, assuming B1 = 25 and B2 = 15 for the prices, weight is entered in B3, then price can be calculated with

    =IF(B3>1,(B3-1)*B2+B1,B3*B1)

    The same principle can be applied to other thresholds. Can you post an example of what you really want to calculate?
    Quote Originally Posted by MarvinP View Post
    Formula always before even thinking Macro.
    Quote Originally Posted by teylyn View Post
    Does that mean that the price for 0.5 kg is also $25? So, everything up to the first full KG is $25?

    If so, your formula is correct.

    What is the question?
    Yes, everything up to the first full Kg is $25. My question is how can I set the formula for decimal places? That formula works well only for 1 Kg increments. If I enter the value as 1.5 Kg, I get a wrong result.

  8. #8
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Macro or Formula to calculate different price thresholds?

    You mean that everything up to the first 1.5 kg is $25?

    If so, try

    =IF(A2>1.5,25+(A2-1.5)*15,25)

    You could also store your increment in a cell, say A1, and then use

    =IF(A2>A1,25+(A2-A1)*15,25)

    This way, when your increment unit changes, you just need to change A1 and don't have to correct the formula.

    cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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