+ Reply to Thread
Results 1 to 6 of 6

Excel email macro failing on sheet array

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Excel email macro failing on sheet array

    Hello, I am trying to adapt a macro from Ron DeBruins website to email an array of sheets but it is failing when it is trying to determine which sheets to send. The error message says "Run-time error '9': Subscript out of range" A second question I have is how do I change this to only email the visible sheets?

    This is the line it is failing on:
    Please Login or Register  to view this content.
    The whole macro:

    Please Login or Register  to view this content.
    Thanks for any guidance you can give!

    Clayton Grove

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel email macro failing on sheet array

    Hello Clayton,

    Your syntax is correct for copying multiple sheets into a new workbook. The error then is caused by a sheet name either being misspelled or it doesn't exist. Hiding the sheet would not cause this error.

    I have change the macro to copy all the visible sheets in the source workbook. If you need only certain sheets to be copied then the macro need a small change.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Excel email macro failing on sheet array

    Leith, thank you for the assistance! I was hoping you would stumble into my thread! I ran your macro but it failed with an error that says "Compile Error: Invalid qualifier" on the section below:

    Please Login or Register  to view this content.
    On this line:
    Please Login or Register  to view this content.

    Any ideas what is causing this?

    Thanks again!

    Clayton Grove

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel email macro failing on sheet array

    Hello Clayton,

    That was fast! Sorry, got rushed and I made a typo. That line should read:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Excel email macro failing on sheet array

    No worries! I changed that line of code and now is give me an error that says "method 'copy'of object 'Sheets' failed" on that same line.

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel email macro failing on sheet array

    Hello Clayton,

    Can you post a copy of your workbook so I can find out why this error keeps popping up?

+ 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