+ Reply to Thread
Results 1 to 5 of 5

Check to see if a sheet exists

  1. #1
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Check to see if a sheet exists

    Hi,

    I've looked around and found a few examples of how to solve this, but I don't want a message box to display and don't want a new sheet.

    I created a command button that deletes a worksheet and clears a couple of list boxes. If the user clicks on the function a second time, an error pops up. what I'd like to do is to have the code check to see if a work sheet exists, and if not, do nothing (except clear the list boxes). Here is my current code. Any help would be great.

    Please Login or Register  to view this content.
    Regards,

    Michael
    Last edited by michaelbails; 05-26-2010 at 01:09 AM. Reason: solved with help - Thanks!!!

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Check to see if a sheet exists

    michaelbails,


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    Please Login or Register  to view this content.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Check to see if a sheet exists

    Removing all the unnecessary selecting, this is how I test for the existence of a worksheet:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Check to see if a sheet exists

    Quote Originally Posted by JBeaucaire View Post
    Removing all the unnecessary selecting, this is how I test for the existence of a worksheet:
    Please Login or Register  to view this content.
    Thanks for the reply...

    The GraphicalResults sheet is a plotted chart (I should have mentioned this in the first place - sorry about that), so the ISREF command is failing. This is the sheet I'm trying to delete. The Patient Data sheet is just for a clearcontents command. The other reply in the thread also didn't work, but I'm very novice at error handling amongst other things with vba.

    any other thoughts?

    Thanks for the help though.

    Mike
    Last edited by michaelbails; 05-26-2010 at 12:54 AM. Reason: additional information about my issue

  5. #5
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Check to see if a sheet exists

    I got it to work!!!

    Thanks for the idea... here is my code:

    Please Login or Register  to view this content.

    Quote Originally Posted by stanleydgromjr View Post
    michaelbails,


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    Please Login or Register  to view this content.

+ 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