+ Reply to Thread
Results 1 to 11 of 11

[VBA] Macro to apply discount to Order Form

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Post [VBA] Macro to apply discount to Order Form

    !UPDATE!

    I have a sample order form with products, quantity, prices & discounts in the attached file.

    I need help in creating a macro such that, when a discount value is entered in C18 and the button is clicked:

    1. the values in column F will be deleted
    2. the discount percentage in C18 will be applied to the value in C16
    3. this discounted amount will be spread over the totals of Product Offering C to A in column I

    4. meaning that if the value in C16 is 10,000 and 50% is entered in C18, and the total of Product Offering C - A are 2000, 3000 and 5,000 respectively (the sum is then the value in C16 =10,000).
    5. the discount value will be 5,000
    6. 2000 of the discounted value (5,000) will be applied to first to Product Offering C. (meaning the sum of Product Offering C will 100% discount)
    7. the remaining 3000 of the discount value will then be applied to Product Offering B. (again, meaning a 100% discount it)
    8. it should always follow this order: Product Offering C --> Product Offering B ---Product Offering A


    I hope the explanation of the problem is quite clear.

    I would appreciate any help with this. Thank you.
    Attached Files Attached Files
    Last edited by Kebad; 10-13-2021 at 04:11 AM. Reason: Update to the problem

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Applying discount to Order Form

    so are you saying that if a discount OTHER THAN the one in cell C17 (34%) is entered in C18 it should override the discount in C17 and change the values in column H, otherwise the values in column H will remain the same? Merged cells BTW create issues, you shouldn't use them if you don't absolutely need them.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Applying discount to Order Form

    Thanks for the reply.

    Not really. Cell C17 would ideally be the same as the value entered in C18 after the computation is done.

    When a value is entered in cell C18, all discount values in column F are rendered irrelevant( ie. " ") . Only the new value in cell C18 should apply. In its application, the value in cell C18 should apply to column H (Total without discount).

    If I enter 10% in cell C18 and the total is 10,000 (discounted value is then 1,000).

    I want this 1,000 to be subtracted first from the of Product Offering C and then on Product Offering B... until the 1,000 is exhuasted.

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Applying discount to Order Form

    column H is the total WITH discount.
    if you want column H to reflect the total, maybe this is what you want in col H...?
    =IF($C$18="",D4*E4*(1-F4),D4*E4*(1-$C$18))

  5. #5
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Applying discount to Order Form

    Sorry for my miscommunication.

    I don't want the new value in cell C18 to reflect on each item on the rows. I would like to value in C18 to apply to total value of the order, where the discount amount is first applied to total value of Product Offering C -A.

    This will then happen when a value is enter in C18:¨
    1. All value in column F are deleted
    2. Take discount on total in C16 using value in C18
    3. The discount amount is spread over the total of Product Offerings C-A in column I

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Applying discount to Order Form

    a couple observations,
    1) the values in col F are hard coded, in F4 for example 2% is coded there, so unless you want to change that to a formula such as =if($C$18="",.02,$C$18)
    and you would have to make those changes throughout col F, is that an option?
    2) if you put that formula I gave you in H4 and drag it down, that will apply the discount down from H4 to H12 and the total in H13 and also in C16 will reflect that total.
    3) column I totals will also reflect those new totals.

  7. #7
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Applying discount to Order Form

    1) Column F is meant to be a hard code for a sales rep to enter a discount so that cannot change
    2)I don't want the value in C18 to apply to all items under column C. I want it to only apply to total and thereafter, the discounted amount spread over values in column I

    Is there a way to do this in VBA?

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Applying discount to Order Form

    I think that’s the only way to accomplish this.
    You might want to private message a moderator to request this post be moved.

    Or close this post and open a new one in the VBA forum and include this post link as additional reference.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Applying discount to Order Form

    It will help if you add expected results to your file with clear explanation of how they are derived i.e. with / without entry in C18.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  10. #10
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: [VBA] Applying discount to Order Form

    !UPDATE!

    I need help in creating a macro such that, when a discount value is entered in C18 and the button is clicked:

    1. the values in column F will be deleted
    2. the discount percentage in C18 will be applied to the value in C16
    3. this discounted amount will be spread over the totals of Product Offering C to A in column I

    4. meaning that if the value in C16 is 10,000 and 50% is entered in C18, and the total of Product Offering C - A are 2000, 3000 and 5,000 respectively (the sum is then the value in C16 =10,000).
    5. the discount value will be 5,000
    6. 2000 of the discounted value (5,000) will be applied to first to Product Offering C. (meaning the sum of Product Offering C will 100% discount)
    7. the remaining 3000 of the discount value will then be applied to Product Offering B. (again, meaning a 100% discount it)
    8. it should always follow this order: Product Offering C --> Product Offering B ---Product Offering A


    I hope the explanation of the problem is quite clear.

    I would appreciate any help with this. Thank you.

  11. #11
    Registered User
    Join Date
    09-29-2021
    Location
    Copenhagen,Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Smile Re: [VBA] Macro to apply discount to Order Form

    Hi guys, I managed to figure it out. Thanks for your help.
    Attached Files Attached Files

+ 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. Applying discount to Order Form with VBA
    By Kebad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2021, 10:30 AM
  2. [SOLVED] Function to automatically discount 10% over an order of £100
    By lanax in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2015, 06:44 PM
  3. Applying discount on order quantity
    By garethm11 in forum Excel General
    Replies: 1
    Last Post: 02-11-2015, 08:59 AM
  4. [SOLVED] Order Form to Summarise Order on another sheet with a Submit Order Button
    By KazzICC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-01-2014, 03:25 AM
  5. Applying a discount to a 5th Day using IF formula
    By ChrisHallas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2010, 02:57 AM
  6. show percentage of order total as a discount
    By DHEKOD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-26-2009, 01:01 PM
  7. Applying a discount to a column of prices!
    By JK in forum Excel General
    Replies: 2
    Last Post: 01-04-2006, 09:30 AM

Tags for this Thread

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