+ Reply to Thread
Results 1 to 8 of 8

Calculating a running total

  1. #1
    Registered User
    Join Date
    07-03-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    4

    Calculating a running total

    Hi guys.

    I figure this has got to be a popular question. I want to calculate a running total (so add a new value to its original value). For example, cell A1 is the one I will be changing daily, and cell B2 is the one that I want a running total in. So if I start with A1 being 5, B2 should be 5. If the next day I type in 3 into A1, B2 should now read 8. However I want to do this for a column length, not just cells A1 & B1. So column B would be the running total of the column A values. If A2 is 3 one day and the next it is 6, B2 should on the second day read 9. And on and on down the columns.


    I tried doing this without VBA using iterations, but that didn't work. Every time I did that it would add values going down, which was weird cuz none of the cells referenced the cell above it. I think I'm forced to use VBA on this one, and I don't know how to use it. Could anyone tell me exactly what I need to type into a VBA module in order to perform this? I looked it up online and there were solutions out there but I didn't know if they would work since I have multiple sheets in this file. (I'm only calculating the running total in one sheet, the others aren't doing anything special.) I need all the sheets in my file and I didn't know if VBA modules are sheet specific/ if you need to be sheet specific when coding. If anyone wants me to attach the file, I can.

    Another question I have (since I know nothing about VBA) is how do modules work? Do you need to turn them on in the Excel spreadsheet itself? Or when you save it does it just automatically apply itself to the file its attached to?

    On another note, if anyone can tell me how to do this WITHOUT VBA, that would be like 100x more fantastic.

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

    Re: Calculating a running total

    There is a very easy way to do this via VBA. Put this in the sheet that you are wanting to do this on:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-03-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    4

    Re: Calculating a running total

    What do I type into the worksheet itself? In other words, how do I call the function in the excel workbook?

  4. #4
    Registered User
    Join Date
    06-02-2010
    Location
    n.ireland
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Calculating a running total

    Hello,

    You put the code into the worksheet change Event and everytime you change the value in A1 the Change Event takes care of the rest.

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

    Re: Calculating a running total

    Correct. Access the Visual Basic Editor. Double click the sheet you want the code to operate on, copy and paste the code in the code window. Go back to your spreadsheet and on the sheet you opted to run the code on, type a number into any row in column A. The code will automatically input add it to the value in column B of the same row.

  6. #6
    Registered User
    Join Date
    07-03-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    4

    Re: Calculating a running total

    Ok. Its still not working for me. Here is what I have. I want column D to be my running total column. Column C is the daily column from which column D should be taking from. I changed the range part of the code to reference column C. Maybe I need to specify the worksheet? If you guys can get this to work that would be SO awesome. workhours.xlsm

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

    Re: Calculating a running total

    You put the correct code in the wrong spot (under module 2) and in the correct spot (sheet1 Daily) you had incorrect code. Removal all the code in the sheet1 Daily procedure and replace with the code you have under module 2. When I did this it worked just fine for me.

    Note: Since it is a worksheet change event you do not need to specify a worksheet.

  8. #8
    Registered User
    Join Date
    07-03-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    4

    Re: Calculating a running total

    OMG IT WORKS (after I took up your edits, stnkynts). Today is a really good day.

    Thanks stnkynts!

+ 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] Calculating commissions with varying percentages based on running total
    By morgan74 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-05-2013, 01:04 AM
  2. Pivot Chart Running Total - Removing Current Year Future Total
    By car3489 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 07-27-2013, 03:35 AM
  3. calculating the total from a running totalizer that resets
    By superchill435 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2012, 11:04 AM
  4. Replies: 0
    Last Post: 04-02-2011, 02:47 PM
  5. Running Total for Calculating Sick Time
    By Mart1n in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2009, 09:17 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