+ Reply to Thread
Results 1 to 8 of 8

Copy all worksheets to new workbook as value

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Copy all worksheets to new workbook as value

    Hi everyone,

    I read a thread on this forum that has a code that will copy all worksheets to a new workbook as values only. I tried using this code but I got a 'run-time error 9' - Subscript out of range

    Can anyone help me? I've got a workbook that has about 8MB of data, but with all the formulas and pivots it balloons to 25MB (I already made sure the pivots are using same datasource, etc - it seems to be the additional formulas that are the issue - hence I want to get rid of them when I share the workbook with others who don't update the book anyway).

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Copy all worksheets to new workbook as value

    the code works for me, you have to have already created the workbook named "Demand Plan Review_APAC.xlsx" and have it SAVED and OPEN for excel to recognize it exists

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all worksheets to new workbook as value

    A subscript out if range error occurs when the sheet name in the code and the sheet name in the file dont match. Check the names and run it again.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    11-08-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy all worksheets to new workbook as value

    OK, that works. However, is it possible for the macro to open a new workbook and paste the data as value (and save it to location 'C:\Foldername\filename' also?)

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all worksheets to new workbook as value

    Try this
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-08-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy all worksheets to new workbook as value

    Great, that works now, file size dropped from 25MB to just under 10MB

    One last question. I tried to save the file as "xlsb" (since it looks like that will drop it down to 5.5MB). But if I change the code to filename.xlsb it doesn't quite like it.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy all worksheets to new workbook as value

    You will need to put in the file format for all files post excel 2007. So replace this line
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-08-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy all worksheets to new workbook as value

    thanks thats perfect now!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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