+ Reply to Thread
Results 1 to 13 of 13

Adding new rows but keeping totals etc. suitably adjusted

  1. #1
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Adding new rows but keeping totals etc. suitably adjusted

    Hi

    In an earlier post, I was given a subroutine from Mike7952 which copies rows of data from one worksheet to other worksheets
    This will be done on a weekly basis with new data captured each week

    The code was as follows
    Please Login or Register  to view this content.
    Is it possible to have some totals, averages etc calculated say 2 rows below the last row of data and be able to then copy a new set of rows of data below the last existing row of data and before the totals, averages etc row?

    Bob M
    Dunedin
    New Zealand

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Try this. Have your formulas include the blank row in between so when a new row is inserted, the formulas will automatically update and include the new data.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Thank you...................

    Run-time error = '9'
    Subscript out of range

    7th row highlighted - Set ws =.............

    Bob M

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Change that line to this...

    Set ws = Worksheets(UCase(Trim(.Cells(iLooper, "A").Value)))

  5. #5
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Thank you...................

    Run-time error = '9'
    Subscript out of range

    7th row highlighted - Set ws =.............

    Bob M

  6. #6
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Thanks..................

    Run-time error '1004':

    Application-defined or object-defined error

    Highlighted 9th row ws.Rows(NextRow).Insert

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Thank you.............no run-time errors but some interesting results

    (1) Enrollment worksheet
    following the existing data - we have a blank row
    then all the new rows added
    then immediately followed by the totals row - BUT totals etc NOT adjusted
    Do my totals formulae require an offset or relative address?

    (2) Weekly worksheets
    I have no totals etc at the moment which is OK, but all new rows are copied immediately next to the existing rows plus the last two are copied again

    Bob M
    Last edited by H28Sailor; 08-27-2016 at 08:48 PM.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Perhaps you could attach an example workbook.

  10. #10
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Hi

    workbook attached

    Bob M
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Try this. The ListObject tables were throwing off the Last data row calculation. This new code uses column B to determine the last data row.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Adding new rows but keeping totals etc. suitably adjusted

    Hi Alphafrog

    Many thanks for your replies and time
    Excellent result

    Bob M

  13. #13
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Adding new rows but keeping totals etc. suitably adjusted

    You're welcome.

+ 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. Adding rows and keeping formulas
    By jesusrms in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-01-2015, 08:50 AM
  2. Adding columns and/or rows while keeping formulas intact
    By KINNEY0201 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-24-2010, 06:11 PM
  3. Excel 2007 : adding more rows/info and keeping formulas
    By zumbajen in forum Excel General
    Replies: 1
    Last Post: 06-10-2010, 06:46 PM
  4. [SOLVED] Keeping users from adding rows but..
    By bjwade62 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2008, 06:02 PM
  5. adding new rows and keeping same formulas
    By email.hue@gmail.com in forum Excel General
    Replies: 3
    Last Post: 03-07-2006, 03:30 PM
  6. [SOLVED] adding new rows and keeping the same formulas
    By email.hue@gmail.com in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-07-2006, 01:15 PM
  7. [SOLVED] Keeping a series table from updating when adding new rows.
    By Jacen Saracen in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-18-2005, 02:05 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