+ Reply to Thread
Results 1 to 11 of 11

Getting the Sum of a Growing List

  1. #1
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Getting the Sum of a Growing List

    I have a list of Employee Numbers and I have created a sheet that counts and adds the number, of reviews that have been done with this and I created a button that adds a new line and formats it I just need a formula that will grow by one row every time I press the button, here is the Module I've made so far, let me know if you need me to add the sheet I can if needed.

    Sub Add_Line()
    'Selects DMs sheet
    Sheets("Richard").Activate

    'Selects the Last 2 Rows of sheet
    Range("Total_Month_R").Select

    'Cuts that and moves it down one
    Range("Total_Month_R").Cut Destination:=ActiveCell.Offset(1, 0)

    'Every thing from here down is to add the Borders
    Range("Total_Month_R").Select
    ActiveCell.Offset(-1, 0).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 1).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 2).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 3).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 4).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 5).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 6).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 7).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 8).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 9).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 10).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 11).Borders.LineStyle = xlContinuous
    ActiveCell.Offset(-1, 12).Borders.LineStyle = xlContinuous

    End Sub

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Getting the Sum of a Growing List

    The following macro works on Excel 2003.
    Your sums in the Total_Month_R row will automatically update as soon as you enter numbers in the new inserted cells.
    I simplified your formatting lines to 1 line.
    Please Login or Register  to view this content.
    Hope this helps
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Getting the Sum of a Growing List

    We use Excel 2007 I believe and it wont update the formula when a Line is added at least not by default maybe I should be looking to see how to change that, any one know?

    Quote Originally Posted by p24leclerc View Post
    The following macro works on Excel 2003.
    Your sums in the Total_Month_R row will automatically update as soon as you enter numbers in the new inserted cells.
    I simplified your formatting lines to 1 line.
    Please Login or Register  to view this content.
    Hope this helps

  4. #4
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Getting the Sum of a Growing List

    bump (self)

  5. #5
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Getting the Sum of a Growing List

    How is the range specified in your formula? Can you copy your formula in your next post? It may have an impact on the way Exçel reacts.

  6. #6
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Getting the Sum of a Growing List

    Sure can here

    =SUM(B2:B26), this is in B27

    The same goes with C-M

    Just an FYI this is the new code, just to make it look better.

    Sub Add_Line()
    'Selects DMs sheet
    Sheets("Richard").Activate

    'Selects the Last 2 Rows of sheet
    Range("Total_Month_R").Select

    'Cuts that and moves it down one
    Range("Total_Month_R").Cut Destination:=ActiveCell.Offset(1, 0)

    'Every thing from here down is to add the Borders
    Range("Total_Month_R").Select
    ActiveCell.Offset(-1, 0).Resize(1, 13).Borders.LineStyle = xlContinuous

    'Asks for New Numbers
    Dim result As String

    result = InputBox("New Driver Number?", "Prompt Richard")
    If result <> "" Then
    Range("Total_Month_R").Select
    ActiveCell.Offset(-1, 0).Value = result
    End If
    'Centers new data
    Range("Total_Month_R").Select
    ActiveCell.Offset(-1, 0).Resize(1, 13).HorizontalAlignment = xlCenter

    End Sub
    Last edited by mmanning; 11-05-2014 at 10:48 AM.

  7. #7
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Getting the Sum of a Growing List

    Bump (self again)

  8. #8
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Getting the Sum of a Growing List

    Change your total formula with this one and your macro will work just fine because this formula is self-adjusting to the number of rows in column A.
    Please Login or Register  to view this content.
    For column B it would be:
    Please Login or Register  to view this content.
    If you don't start at row 1 change A1 for A5 or whatever row you start at in the formula.

  9. #9
    Registered User
    Join Date
    09-25-2013
    Location
    Loysville, PA
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Getting the Sum of a Growing List

    Worked perfectly, thank you sir, I am curious why this works so I will, be looking into that, rep heading your way fine sir.

  10. #10
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Getting the Sum of a Growing List

    this sum works because it starts at cell B1.
    Then the Row() function returns the cell position of the formula while the "INDEX(B:B,ROW()-1)" points to the cell just above it (Row()-1).

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,042

    Re: Getting the Sum of a Growing List

    mmannning, 2 things...

    1. Forum rules require to wait at least a day before bumping.

    2. Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Button that adds one row to growing list
    By swedum in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 11-25-2013, 01:27 PM
  2. Macro to add new entry to growing list pls
    By lister in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-22-2013, 11:27 AM
  3. Replies: 10
    Last Post: 08-12-2010, 08:01 AM
  4. [SOLVED] count unique items in ever-growing list?
    By MeatLightning in forum Excel General
    Replies: 2
    Last Post: 03-17-2006, 02:10 PM
  5. Calculate a growing list of data
    By jhalverson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2005, 06: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