+ Reply to Thread
Results 1 to 13 of 13

VBA for Saving Multiple Tabs to New File

  1. #1
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    VBA for Saving Multiple Tabs to New File

    All,

    Thank you for your help. I am trying to get a macro to generate reports for me, and save different tabs as different files. My macro will currently save EVERY tab as a new file, but I now want to spread out my data to be easier to read, so I'd like it to save every 2 tabs as a new file. I've attached a sample spreadsheet with my macro saved to it (note that the numbers were made up by me just now). I'd like to get the new macro to save the first two tabs as 1 file, and the second 2 tabs as another file. The code I'm currently using to save tabs as files is:
    Please Login or Register  to view this content.
    Any help you can give me would be greatly appreciated.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA for Saving Multiple Tabs to New File

    in your example sheet names are
    44001_Summary
    44002_detail
    44003_Summary
    44003_detail

    are you looking to group every detail with summary ?
    as logically 44001 and 44002 dont go together?
    are you missing two tabs or does two actually go together? if the later...what logic makes them go together...just being next to each other?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA for Saving Multiple Tabs to New File

    Try change the loop to
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    My mistake. The first tab should be labeled 44002_Summary followed by 44002_detail.

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA for Saving Multiple Tabs to New File

    in that case jindon's solution should work perfectly for you as long as your same number Summary and detail sheets are right next to each other and your sequence is in the correct order

    ie sheets
    1,2 - 3,4 - 5,6 - etc

  6. #6
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    I get an error saying: "Run-time error '424': Object required"

    I now have the code reading:

    Please Login or Register  to view this content.
    Did I insert the command correctly?

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA for Saving Multiple Tabs to New File

    Try change to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    Now the error says "Subscript out of range". The code currently reads:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    While I got that error. The files were still all created and saved! Thank you for your help!

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA for Saving Multiple Tabs to New File

    Got no error.

    Just added for the safety
    Please Login or Register  to view this content.
    for the safety...

  11. #11
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    I'm still getting a subscript out of range error with the new FileFormat:=-4143 piece.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA for Saving Multiple Tabs to New File

    See the attached

    Macro Demo revised.xlsm

  13. #13
    Registered User
    Join Date
    10-12-2015
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2010
    Posts
    29

    Re: VBA for Saving Multiple Tabs to New File

    Worked like a charm! Thank you.

+ 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. Saving Multiple Tabs as New Excel File
    By mmcconkie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2015, 04:47 PM
  2. [SOLVED] Saving multiple file versions in the same folder if file already exists
    By lsargent in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2015, 10:49 AM
  3. VBA move multiple and selected sheets/tabs to new file and copy file as value
    By NeilM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2013, 06:19 AM
  4. Replies: 1
    Last Post: 10-04-2012, 08:11 PM
  5. Consolidating multiple files into one excel file with multiple tabs
    By Chemistification in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2012, 06:23 AM
  6. Remove Tabs when saving to another file type
    By ea73 in forum Excel General
    Replies: 11
    Last Post: 10-25-2011, 11:09 PM
  7. Saving to text file - tabs from empty cells ignored
    By lif in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2006, 11:51 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