+ Reply to Thread
Results 1 to 4 of 4

Show an error msg when naming sheet using vba

  1. #1
    Registered User
    Join Date
    01-11-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    96

    Show an error msg when naming sheet using vba

    I have a sheet that takes a cell value and uses it as the name for a new sheet. Unfortunately some of the people using the sheet don't check to see if there is already a sheet with that name in the index and i have to trawl through trying to find incorrectly named sheets. Is there a way of generating an error message if there is already a sheet with the same name? Button code below. Thanks for taking the time to look

    Please Login or Register  to view this content.
    Cheers

    Ross

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,858

    Re: Show an error msg when naming sheet using vba

    Ross-
    It would be really helpful in helping you, if you uploaded the workbook that this applies to so that we can see the whole picture. It is sometimes easier to repair the wheel instead of designing a whole new one.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Show an error msg when naming sheet using vba

    Or maybe something like this if I understand things right.

    Please Login or Register  to view this content.
    BTW, read up about "selecting" in Excel and why it should be avoided. (Google is your best friend here)

  4. #4
    Registered User
    Join Date
    01-11-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Show an error msg when naming sheet using vba

    alansidman: I have attached (I think) an abbreviated copy of the file (the original contains a lot of sheets). The buttons that use the required code are on the template sheet

    jolivanes: I added your code and I think it will work (with some 'adjusting' perhaps (it is in the attached file)

    Apologies for my code, I am self taught and although I have been using VBA for quite a few years I don't really do it enough to get out of bad habits. I tend to find code that sort of does what I need and adjust to suit my requirements
    Attached Files Attached Files

+ 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] Show all on Protected Sheet - error
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-13-2014, 04:10 PM
  2. Problem with Vlookup - have value in sheet but show error #N/A
    By whaaz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-10-2013, 09:17 AM
  3. Error in formula to show sheet name
    By tryckman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-09-2012, 03:49 PM
  4. Module.Name Naming error
    By MingVBA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2011, 12:24 AM
  5. Subscript out of range- sheet naming error?
    By catccc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2010, 01:51 PM
  6. Error Naming Tabs
    By Hoffhines in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2008, 04:24 PM
  7. naming tab macro error runtime error 1004
    By D in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2005, 10: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