+ Reply to Thread
Results 1 to 14 of 14

Insert lines at change of data and add sub totals to copy to new tab (do through a loop?)

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Insert lines at change of data and add sub totals to copy to new tab (do through a loop?)

    Hi Experts,

    I have attached a spreadsheet that I hope explains what I am trying to do but here is an explanation as well. I have data on one tab Columns C - M. For every change in Column C I need to sum the values in Column I. I then need to make a summary of those data points on Sheet2. I am not sure if this could all be done through a loop or if the original data needs to be reformatted. I am fine either way, I am just getting stuck in trying to get the insert and the sum to work and the copy on the inserted rows over to the summary sheet. Any help would be greatly appreciated. Please see the attached Excel file for a better, I hope, layout of what I am trying to do. Please let me know if I need to clarify what I am asking.

    Thanks agiain,

    theglitch
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,662

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    deleted....
    Last edited by protonLeah; 10-01-2019 at 05:29 PM.
    Ben Van Johnson

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,881

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Macro approach:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Hi Mumps1,

    Thank you for the quick reply. It looks like it is almost working I am just getting a debug error on the line .Cells(.Rows.Count, fnd.Column).End(xlUp).Offset(1, 0) = tot

    It is copying over the first document number from column C but nothing else. Thanks again for the help. Any additional help would be greatly appreciated.

    A2 on Sheet2 is the only field getting populated.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,881

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    I tested the macro on the sample file you posted and it worked properly. If you tried the macro on a different file that probably caused the problem. If you used it on a different file, please post a copy of that file, de-sensitized if necessary.

  6. #6
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Thanks. I am trying to run on a different spreadsheet but I am also testing on the file I uploaded and it is doing the same thing. I have version 1902 O365 would that make any difference?

  7. #7
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    The filter is only selecting the first document in the list and hiding the second one. I then get the debug screen popping up. I am not sure if that helps at all or not.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,881

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    I'm not sure what you mean by "version 1902 O365". Are you using Excel 2010 or Excel 2013? Can you post a copy of the different file?

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Hi ! SubTotal Excel feature …

    Quote Originally Posted by theglitch View Post
    I am not sure if this could all be done through a loop
    or if the original data needs to be reformatted.
    Nothing to amend, just directly use the Data SubTotal Excel feature !
    And if you really need a code so just with the same Range.Subtotal method in a single codeline …

  10. #10
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Excel 2016

    Replace Sheet1 with Audit Data to make it the file I am using. Everything else is the same. I just changed the sheet name in the macro to run for that sheet name instead. I can't get the Sample File to run though. Thanks again

  11. #11
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Hi Marc L,

    Thanks for the help, but I am stuck on how that moves it to Sheet2 with only the subtotals for the amounts for the changes in Column C on Sheet1. Thanks again for the help.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,881

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    Try the attached file.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    That seems to be working. Let me test it a bit more. Thank you very much.

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,881

    Re: Insert lines at change of data and add sub totals to copy to new tab (do through a loo

    You're very welcome. Let me know how it works out.

+ 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] Loop and copy every x lines of range
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-12-2018, 05:53 AM
  2. VBA to copy data with each change in reference number, save & loop
    By Marijke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2015, 10:23 AM
  3. Code to Copy and Insert lines
    By Phill Palmer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2013, 12:00 PM
  4. [SOLVED] Loop through entire sheet, Insert row, copy row data, paste row data, delete row
    By Hyperdude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2012, 01:46 AM
  5. Copy paste data, insert rows, insert data and change . to -
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2010, 01:44 AM
  6. Macro to insert lines and copy
    By AdrianLeCoyte in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2007, 03:28 PM
  7. Macro to insert lines and copy
    By punter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2007, 12:20 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