+ Reply to Thread
Results 1 to 9 of 9

Macro for splitting the number to a specific proportion

  1. #1
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Macro for splitting the number to a specific proportion

    Dear all,

    Attached the excel. Columns A to D is the raw data while Columns F to I is the result I want.
    I want to split the invoice number to three difference invoice number and the quantity split according to the proportion 5:3:2.
    However, the quantity must be integer and the split total quantity need to match with the original quantity of each item.
    In the example, if the decimal place is 0.5, I can't use round up or round down because it may not match with the original quantity.
    Is there anyway to solve this issue?

    Thanks
    Jack
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Macro for splitting the number to a specific proportion

    Surely this may not be possible.

    Split is 5:3:2, ie 50% 30% and 20%
    If the total invoice is 100, the split would be 50, 30, 20 - thats fine.
    If the total invoice is 150, the split would be 75, 45, 30 - thats fine.

    If the total invoice is 163 the split should (mathematically) be 81.50, 48.90 and 32.60

    But you say the result must be integers, then you'd have to take the integer amount or round up or down, which would, in all cases, change the split values 5:3:2 very slightly and unless you adjust the final figures properly they may not add up to the original total.

    Who made these rules in the first place?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Re: Macro for splitting the number to a specific proportion

    Hi, thanks for your reply. I also think it is not possible in some case.

    So I would like to change the split to 6:4 and it should be matched with the original quantity.

    But how can I split the invoice to two (add A,B after the invoice number) according to the split quantity?

    Attached the new excel. Thanks.
    Attached Files Attached Files
    Last edited by jackyung; 10-24-2019 at 09:44 PM.

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Macro for splitting the number to a specific proportion

    It doesn;t matter what the split is - you're gonna get the same problem again.

    Lets say the invoice is 100, with 6:4 the result would be 60 and 40 - both integers, together they add up to 100 - that's fine.
    Or let's say the invoice is 240, with 6:4 the result would be 144 and 96 - both integers, together they add up to 240 - that's fine.
    But if the invoice value is 113 that would be 67.8 and 45.2
    And you're saying you want integers but but you want the sum of them to be exactly the total.
    It's not gonna work with 113 (or a whole host of other numbers).

    That's like saying
    I'm gonna start with two numbers, 4 and 7.
    I want to add them together.
    I don't want the total to be 11.
    But I'm not allowed to change them to anything else, they must stay at 4 and 7.
    How can I make the total something other than 11 without changing either number.
    You can't.

  5. #5
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Macro for splitting the number to a specific proportion

    I don't understand idea of that but in the case of split for 2 values (6:4) you can ex. rounddown part 60% and roundup part 40%, then you will get two integers and also sum will match with original value.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  6. #6
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Re: Macro for splitting the number to a specific proportion

    Hi KOKOSEK,

    That's what I want to mention. 113 that would be 67.8 would become 68 and 45.2 would become 45 after rounding.

    Hi Special-K

    Now the major issue is how to split a invoice to two invoice with split value according to the format I want (Column F to I).

    Thanks for both kindly helping

  7. #7
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Macro for splitting the number to a specific proportion

    It is hard to really help if we don't understand the idea but I am happy that my advise could be helpful.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Macro for splitting the number to a specific proportion

    Simply
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Re: Macro for splitting the number to a specific proportion

    It seems perfect! Thanks for all which helping in this thread. I really appreciate!

+ 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. [SOLVED] Discount to be distributed in proportion
    By ahblur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2017, 01:43 AM
  2. Need help creating a macro splitting up number ranges
    By rostar99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2013, 12:39 PM
  3. [SOLVED] Macro to generate a random number between 2 specific values into specific cells.
    By Nerfmagnet in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2013, 11:45 AM
  4. Proportion of Averages
    By fredmeister in forum Excel General
    Replies: 3
    Last Post: 09-28-2011, 06:12 AM
  5. Help with incremental proportion shifts?
    By Farvenugen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-24-2011, 07:49 PM
  6. Keep Graphs in Proportion
    By iambinary in forum Excel General
    Replies: 0
    Last Post: 03-26-2009, 01:13 PM
  7. Raise numbers in the same proportion..
    By PaMeLa in forum Excel General
    Replies: 3
    Last Post: 02-16-2006, 03:35 PM

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