+ Reply to Thread
Results 1 to 12 of 12

Confirm Worksheet does not exist

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Confirm Worksheet does not exist

    Hi All (again) lol

    i have a quick query, looking to do the following,

    i have a piece of code that names a new work sheet after a cell value.

    if the user enters the same date that has a sheet that already exists in the workbook then it crashes out with the "same name" error.

    What i have been trying to do is implement a check to see if the cell value which i pass to a string already exists. but im not sure how to check all worksheets and see if the name is already there.

    if someone could give me a pointer it would be greatly appreciated.

    many thanks
    Dave

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Confirm Worksheet does not exist

    Please Login or Register  to view this content.
    Last edited by AB33; 07-10-2014 at 06:35 AM.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,669

    Re: Confirm Worksheet does not exist

    In a new workbook, Sheet1 will exist and Sheet4 will not exist.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  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,198

    Re: Confirm Worksheet does not exist

    Hi, Dave,

    Please Login or Register  to view this content.
    Ciao,
    olger
    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

  5. #5
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Confirm Worksheet does not exist

    RIght im totally lost,

    my code below, as it has been given by someone working with me for review, i simply added a sheet name part as they recorded the whole thing and i did a quick tidy and added a quick enter date check at the start.




    Please Login or Register  to view this content.

    I thought the check would have been something similar to

    Please Login or Register  to view this content.


    should i be using an error check or a do while loop?

    i relatively new to vba and spend a good bit of time with vb.net but im a total novice...

    so im happy for all advice as i like to try and get there myself in the end
    Last edited by unreal_event_horizon; 07-10-2014 at 06:50 AM.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Confirm Worksheet does not exist

    Please Login or Register  to view this content.
    Last edited by AB33; 07-10-2014 at 06:59 AM.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,669

    Re: Confirm Worksheet does not exist

    With the function that I provided, your code would look like:

    Please Login or Register  to view this content.

    Regards, TMS

  8. #8
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Confirm Worksheet does not exist

    have it working now, many thanks for all your input.

    I have a question if anyone wants to give me a quick explanation. the code in the tags is the working code.

    but i want to know in basic english what this is telling me.....

    Please Login or Register  to view this content.
    am i right in thinking, if the sheet name does not exist then.......

    could i be so rude to ask for this line to be broken down better than that?



    Please Login or Register  to view this content.
    Last edited by unreal_event_horizon; 07-10-2014 at 07:08 AM. Reason: i cant spell in plain english, lol

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Confirm Worksheet does not exist

    In plain English yes

  10. #10
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Confirm Worksheet does not exist

    Quote Originally Posted by TMS View Post
    With the function that I provided, your code would look like:

    Please Login or Register  to view this content.

    Regards, TMS
    apologies for not testing, this TMS, when creating a function, do i create a new module, save the function in there and call it back like any other macro by name when i want to use it?

  11. #11
    Registered User
    Join Date
    08-03-2012
    Location
    Cork Ireland
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: Confirm Worksheet does not exist

    Reputation added to all, many thanks for your input

    Dave

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,669

    Re: Confirm Worksheet does not exist

    You're welcome. Thanks for the rep.


    when creating a function, do i create a new module, save the function in there and call it back like any other macro by name when i want to use it?
    Essentially, yes. Doesn't have to be in its own module but I consider it best practice. If you rename the module, it's easier to find things.

    Regards, TMS

+ 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. [SOLVED] how to run macro or msgbox when Worksheet does not exist/exist
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2013, 10:54 PM
  2. [SOLVED] using macro to check worksheet if data input in another worksheet exist.
    By Curtis goh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2013, 01:02 AM
  3. i need a macro if a worksheet name exist rename to a new worksheet
    By daillest319 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2012, 04:55 PM
  4. Replies: 4
    Last Post: 06-18-2006, 01:10 PM
  5. Confirm before deleting a worksheet?
    By edeil in forum Excel General
    Replies: 1
    Last Post: 01-27-2006, 10:50 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