+ Reply to Thread
Results 1 to 3 of 3

Checking for a sheet

  1. #1
    Registered User
    Join Date
    02-15-2006
    Posts
    93

    Checking for a sheet

    Good morning,

    I was wondering if it is possible to check to see if a sheet exists in a workbook and if it does, delete it. The reason I am asking is that I have something that adds sheets to run various reports and then deletes the sheet once the report has run. The error handling kicks them back to the main menu if something goes wrong.

    The problem is that if an error happens while trying to run one of the reports, the next time it tries to run the report it is going to generate an error when it tries to name the new sheet that was added for the report. Any ideas?

    For example, I want to test if any of Sheets("Report1"), Sheets("Report2"), Sheets("Report3") exist and if so, delete whichever one.

    Thanks,
    dw

  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
    Hello Toocold,

    This macro will delete the worksheet named if it exists.

    Please Login or Register  to view this content.
    Examaple:
    DeleteSheet "Report3"

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-15-2006
    Posts
    93
    Thanks Leith,

    That was exactly what I needed to get things working.

+ 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