+ Reply to Thread
Results 1 to 5 of 5

Count the number of values required to sum to a total

  1. #1
    Registered User
    Join Date
    05-30-2014
    Posts
    11

    Count the number of values required to sum to a total

    I posted this problem in the "functions" area and had two very helpful responses which solved the issue for a small data set. However the dataset Im dealing with is relatively large (280 columns x 8760 rows) and dragging the function into that many cells ate up all my CPU and the calculation speed was abysmal (CPU actually overheated and forced a reboot!). It was suggested that therefore a macro may be the best way to solve the problem.

    The orignial post is located here:

    http://www.excelforum.com/excel-form...ml#post3824265

    However, I thought it may help to add a little more context to the problem and also to get a VBA solution for the entire routine and not just the portion requested in the original post (above).

    Context:
    The calculation can best be thought of in terms of velocity and distance. I have a data set which has a measured velocity at hourly time points for a total of 8760 hours. I also have a set number of distances which are required to be traveled (280 different distances). The units for distance are arbitrary and the distances range from 1-280. Additionally, each distance of the 280 distances is required to be travelled a different number of times (you can think of this as being that there are different numbers of "cars" travelling these distances at the velocities in the dataset). At each hourly time point the "cars" set off on their journey and looking down the data set I know the speeds they will travel at over the next hours. I need to be able to calculate the time it takes for all the "cars" to travel the required distance for each time point and to calculate the average time for each hour.

    I have attached a spreadsheet of a limited data set to show what is required which should hopefully better explain the calculation. This is only a small section of the data set, as mentioned before the full data set has 8760 hours of velocity data, 280 different distances and a total of 100 "cars". Ive broken the calulcation down into 3 sections:

    1. Calculate time to required distance for one car setting out at each time point
    2. Calculate total aggregate time for all the cars making all their journeys
    3. Divide the total aggregate time by the total number of cars to derrive the average time.
    Ave time taken.xlsx
    All suggestions/comments are gratefully recieved.

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Count the number of values required to sum to a total

    Check the sound. Push the button on Sheet2 and result outputs on Sheet1.
    Ave time taken.xlsm

  3. #3
    Registered User
    Join Date
    05-30-2014
    Posts
    11

    Re: Count the number of values required to sum to a total

    Well, Im astounded.

    It seems to work perfectly. For the entire massive data set the total calculation time is about ten seconds. Excellent work!!!

    I'll play around with it a bit to make sure its doing what I think its doing and then I'll mark the thread as solved.

    I'm delighted, thank you so much!

  4. #4
    Registered User
    Join Date
    05-30-2014
    Posts
    11

    Re: Count the number of values required to sum to a total

    Well after a few days of playing with it, it seems you wrote a very robust/versatile macro!

    Many, many thanks

  5. #5
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Count the number of values required to sum to a total

    You are wellcome!

+ 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] Count number of values required to sum to total
    By LAUGHINGCROW in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-08-2014, 04:34 AM
  2. Replies: 3
    Last Post: 06-12-2013, 10:53 PM
  3. Replies: 3
    Last Post: 10-27-2012, 04:16 AM
  4. Return location when values add to total required
    By tarquinious in forum Excel General
    Replies: 5
    Last Post: 08-31-2011, 10:28 AM
  5. Total values required for each week
    By mbruce3 in forum Excel General
    Replies: 2
    Last Post: 06-20-2011, 07:13 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