+ Reply to Thread
Results 1 to 12 of 12

Sum numbers under a threshold

  1. #1
    Registered User
    Join Date
    07-23-2014
    Location
    Manchester, England
    MS-Off Ver
    2013
    Posts
    8

    Sum numbers under a threshold

    Hi Everyone,

    I'm trying to write a macro in VBA which sums up a list of numbers up to but not over a limit (10,000.00) starting from the top and then return the sum at the bottom of the column. I'd also like it to return the sum of the related numbers in the next column as well. I think this is best expressed in my example below. Column A is the column which I'm referring to for the 10,000 limit.

    Macro example.PNG

    The 10,000 limit is breached in column A at row 13 where the total is 10,431.15 so I need to return the sum of the entries before this point (i.e. sum of the numbers in A1 to A12 in this example) which would be 9424.54. At the bottom of column B the corresponding entries pre the 10,000 breach in column A are 282.83 (i.e. sum of the numbers in B1 to B12).

    I'm fairly new to VBA so any help or guidance would be greatly appreciated.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sum numbers under a threshold

    dislexic37,

    Is the idea that the summed group also gets highlighted as per your image? Is the image the actual format? (i.e. columns A and B and no headers?)
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    07-23-2014
    Location
    Manchester, England
    MS-Off Ver
    2013
    Posts
    8

    Re: Sum numbers under a threshold

    Hi Arkadi,

    No the highlighting was just to help with the explanation of which numbers I was trying to get to sum (i.e. when the 10,000 limit was reached). There will probably be a header in row 1 but I thought that if I solved the problem without headers then I'd be able to shift the result down one when I added a header.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sum numbers under a threshold

    Ok, this will work i think, but you won't know up to where the numbers were summed? Check this:

    Please Login or Register  to view this content.
    Last edited by Arkadi; 07-23-2014 at 11:51 AM.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Sum numbers under a threshold

    Here is my go at it.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-23-2014
    Location
    Manchester, England
    MS-Off Ver
    2013
    Posts
    8

    Re: Sum numbers under a threshold

    Hi Arkadi,

    The sum at the bottom of column A is spot on. At the bottom of column B it appears to be adding A1 to A12 and then adding the value in A12 to give 11,381.94 rather than the sum of B1 to B12.

  7. #7
    Registered User
    Join Date
    07-23-2014
    Location
    Manchester, England
    MS-Off Ver
    2013
    Posts
    8

    Re: Sum numbers under a threshold

    Stnkynts,

    Your solution gives 9,805 as the sum for column A and then adds up the whole of column B.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sum numbers under a threshold

    dislexic my bad... here's the fix:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Sum numbers under a threshold

    dislexic my bad... here's the fix:

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Sum numbers under a threshold

    Another alternative,

    Please Login or Register  to view this content.
    Cheers, berlan

  11. #11
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Sum numbers under a threshold

    Stnkynts,

    Your solution gives 9,805 as the sum for column A and then adds up the whole of column B.
    It doesn't on my test workbook.

  12. #12
    Registered User
    Join Date
    07-23-2014
    Location
    Manchester, England
    MS-Off Ver
    2013
    Posts
    8

    Re: Sum numbers under a threshold

    Thank you everyone for you help, problem solved. Cheers.

+ 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. Sum up tp a Threshold
    By TylerJamison in forum Excel General
    Replies: 1
    Last Post: 08-30-2012, 02:31 PM
  2. threshold and audit
    By step_one in forum Excel General
    Replies: 2
    Last Post: 10-14-2011, 11:10 AM
  3. Tax Threshold formula
    By Raj Singh in forum Excel General
    Replies: 2
    Last Post: 08-17-2011, 12:14 AM
  4. Count during a 30 day threshold
    By cc1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-11-2008, 04:37 PM
  5. How do I sum numbers up to an certain threshold in Excel?
    By Stuck Student in forum Excel General
    Replies: 4
    Last Post: 04-30-2005, 02:06 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