+ Reply to Thread
Results 1 to 5 of 5

Sum all above cells until you reach a blank cell

  1. #1
    Registered User
    Join Date
    10-04-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    8

    Sum all above cells until you reach a blank cell

    Hello All,

    I have values in a column that also contains some blank cells. I would like to sum the values between the blank cells, and put the total in the next column.

    Here is what i have:
    1
    2
    3

    5
    6

    4
    9
    8
    3

    I would like the sums to appear so there is a 6 in the cell beside the blank after "3". There is an 11 in the cell beside the blank after "6". There is a 24 in the cell beside the blank after "3"

    I wrote the following code, but it only gives the cell value of the cell above the blank. I need help fixing this code.

    Please Login or Register  to view this content.
    Thanks
    Last edited by vba-amateur; 10-09-2017 at 02:19 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,701

    Re: Sum all above cells until you reach a blank cell

    What is variable FirstColumn? tot? If they are Range variables then here is what I would do:

    Please Login or Register  to view this content.

    Also I strongly recommend to everyone that they declare variables. Doing so prevents a lot of bug and runtime errors.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-04-2017
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    8

    Re: Sum all above cells until you reach a blank cell

    Thank you so much for the quick response! I've been stuck on this for ages! The code works PERFECTLY.

    I understand that:
    The sum value that we are trying to find = Total
    Total starts of as 0.

    But, for
    Total =Total + tot

    how does the code know which "tots" to add?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,701

    Re: Sum all above cells until you reach a blank cell

    It starts at zero then keeps adding "tot" until it reaches a blank line. When that happens, it shows the total and starts at zero again.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Sum all above cells until you reach a blank cell

    You could also do this with the following worksheet formula (in B2 and copied down):
    Please Login or Register  to view this content.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

+ 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. Replies: 3
    Last Post: 02-07-2023, 11:28 AM
  2. [SOLVED] Formulas within IFs. In a col, ignoring blank cells above until you reach a number then +1
    By MushroomFace in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-24-2014, 06:45 PM
  3. [SOLVED] Insert blank rows to reach 20
    By RomanGriffen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2014, 12:42 PM
  4. Replies: 0
    Last Post: 05-08-2012, 12:42 PM
  5. Replies: 1
    Last Post: 10-07-2011, 10:26 AM
  6. [SOLVED] loop macros until reach blank in adjacent column
    By McKCollins in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2006, 06:10 PM
  7. [SOLVED] I need to add a range of cells until I reach a cell with a zero va
    By tower_of_love_m in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-27-2006, 05:50 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