+ Reply to Thread
Results 1 to 5 of 5

I need to Sum a group of cells that varies each time

  1. #1
    Registered User
    Join Date
    07-04-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    27

    I need to Sum a group of cells that varies each time

    Hi,

    I am trying to think of how to do this loop activity in a macro. Let me try and explain...

    I have two columns, the one on the left is populated with various lines of data which varies in number (usually about 50). The data in this column has been sorted and once sorted, blank lines have been inserted between sets of data. So going from the top of the column you might have say one populated cell then a blank then 3 populated cells and then a blank and then 5 populated cells and then a blank and then one populated cell.

    What I need the macro to do is go down the column and in the right hand column, one the last cell of each section, sum the cells on the left.

    So for instances example 1 would become example 2 (also see attached example in Excel File):ExamVBA.xlsx

    Example 1
    345
    587
    125

    Eaxmple 2
    345
    587
    125 Total 1057

    The process would be repeated until the end of the data is reached.

    Does that make sense?

    TLP
    Last edited by TheLittlePrince; 09-19-2013 at 10:23 AM. Reason: Amend title

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Tricky Loop! Can't think how to do it - please help!

    How about:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Tricky Loop! Can't think how to do it - please help!

    Try this:-
    Please Login or Register  to view this content.
    Regards Mick
    Last edited by Fotis1991; 09-19-2013 at 10:38 AM.

  4. #4
    Registered User
    Join Date
    07-04-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: I need to Sum a group of cells that varies each time

    Hi Mick,

    Your solution part worked.

    I tested another random worksheet and it did it for the first 4 entries and then broke down when it had to do 3 consecutive cells.

    Here was the results:

    72,866.32 72,866.32

    607,585.14
    -2,900,000.00 -2,292,414.86

    61,374.44 61,374.44

    -3,161,183.00 -3,161,183.00

    2,827,258.00
    -281,980.00
    -2,545,277.00 1.00

    2,307,813.00
    -281,980.00
    -2,025,833.00 .

    2,307,813.00
    -281,980.00
    -2,025,833.00 .

    3,086,980.00
    -281,980.00
    -2,805,000.00 .

    3,866,147.00
    -281,980.00
    -3,584,166.00 1.00

    3,736,285.00
    -281,980.00
    -3,454,305.00 .

    0
    -500,000.00
    -12,239,726.00 -12,739,726.00

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: I need to Sum a group of cells that varies each time

    Could you send the faulty data in an attached file

+ 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. Loop Macro + Very Hidden Sheets = Tricky?
    By lilanngel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2014, 03:38 AM
  2. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  3. Tricky Tricky episode 2!!!
    By mhax in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-21-2006, 10:15 AM
  4. A Tricky One......
    By nevi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2006, 09:10 AM
  5. [SOLVED] Help Please! (This one is a bit tricky)
    By Dean Goodmen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2005, 09:00 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