+ Reply to Thread
Results 1 to 10 of 10

Export Specified Worksheets

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Export Specified Worksheets

    I'm using the following code to export all worksheets in a workbook into individual sheets, however in my main workbook I have three sheets which appear before the sheets I want to export that I don't want to export every time the macro is run. Is there any way to adapt the macro so that it skips the first specified number of sheets or exports from sheet 'X'

    Many thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Export Specified Worksheets

    Hi, HangMan,

    you may rely on the Index of the worksheets although I would prefer to use an array or a string with the codenames of the sheets to skip:
    Please Login or Register  to view this content.
    I changed your variable FileName as it is used as a VBA KeyWord.

    Ciao,
    Holger
    Last edited by HaHoBe; 02-17-2014 at 06:48 AM. Reason: altered code
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Export Specified Worksheets

    Hi Holger,

    That works well, thank you. If you were to adopt your preferred method of using an array or a string with the codenames of the sheets to skip, how would you go about doing this. I think that has to be a more foolproof methid right?

    I have very limited VBA experience, so unure how you would intergrate this?

    Many thanks

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Export Specified Worksheets

    Hi, Hangman,

    the sample for the sheetnames may look like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    04-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Export Specified Worksheets

    If it is OK to ask in this thread, how would I do the same thing except export to individual PDF files?

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Export Specified Worksheets

    Hi, dmarzean,

    Forum Rule #2 asks you to start your own thread and maybe provide a link to this thread if needed.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    04-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    37

    Re: Export Specified Worksheets

    Done. Thank you sir.

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Export Specified Worksheets

    Hi Holger,

    Um, all seems to work fine on a sample sheet, but when applied to my main sheet (which I can't upload due to sensitivity of data), I get a Runtime Error 1004, as follows:

    The file could not be accessed. Try one of the following:

    Make sure the specified folder exists
    Make sure the folder that contains the file is not read-only
    Make sure the file name does nor contain any of the following characters: <> ? [] : or *
    Make sure the file/path name doesn't contain more than 218 characters

    All the conditions are met, so I am totally baffled as to what is causing the error?

    The error appears to be in these lines of code

    Please Login or Register  to view this content.
    Am I missing something, any thoughts?

    Many thanks

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Export Specified Worksheets

    Hi, Hangman,

    check the TrustCenter in Excel if the access to that folder is set, make sure you have access to that folder by checking with the Windows Explorer, as I received a new AntiVirus-Program today check if any settings have been modified in/from taht software, if Windows- or Office-updates have been installed, have a look at http://support.microsoft.com/kb/213983/en-us.

    Ciao,
    Holger

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Export Specified Worksheets

    Hi Holger,

    I have no problems running the code on a simple sample file I have, exporting to the exact same folder, so it isn't the folder, the file name doesn't exceed 128 characters or contain any illegal characters, so I am truly baffled and not sure what else to test for as there is no noticable difference in the process. Could there be anything in the file itself it doesn't like?

    Are there any other things you can thing of to check?

    Many thanks

+ 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. Export Multiple Worksheets to CSV
    By dleininger in forum Excel General
    Replies: 2
    Last Post: 06-23-2013, 02:23 PM
  2. [SOLVED] Export Individual Worksheets
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-30-2013, 06:37 AM
  3. Replies: 1
    Last Post: 10-30-2012, 06:34 PM
  4. Export worksheets
    By mjhopler in forum Excel General
    Replies: 2
    Last Post: 06-14-2010, 01:02 PM
  5. XML Export and worksheets
    By WHoit in forum Excel General
    Replies: 0
    Last Post: 03-15-2005, 07:06 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