+ Reply to Thread
Results 1 to 2 of 2

Replace runtime 1004 message

  1. #1
    Registered User
    Join Date
    03-04-2020
    Location
    San Francisco, CA
    MS-Off Ver
    Office 2016
    Posts
    3

    Replace runtime 1004 message

    I have a macro that creates a copy of a worksheet (in same workbook) at the click of a button. they select a customer name, hit the button, then it creates a worksheet with the customer name as the ws name. If they already created a ws for that customer, I get a runtime error 1004 but the sheet is created without the customer name. I would like to just change the text in the runtime error message, or add to it. For an easy example...


    Sub Error1004_Example()

    Worksheets("Sheet2").Name = "Sheet1"

    End Sub


    I would like the error message for this to read:
    "You already created a page for this customer. Please select another customer or change the name of the tab manually."

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,855

    Re: Replace runtime 1004 message

    Rather than using err handle, I'd recommend using IsObject to check if worksheet exist already.

    Ex:
    Please Login or Register  to view this content.
    If function returns true, then show message using MsgBox. If false, proceed with process.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

+ 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. Runtime error 1004- duplicate sheetname, how do I add a warning message?
    By adrianrd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2020, 12:12 PM
  2. Runtime Error '1004':
    By ankamshetti.nagaraj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-26-2017, 10:31 PM
  3. runtime error 1004
    By madhatter40 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2014, 04:19 PM
  4. Need to Create Error Message Box during Runtime error 1004
    By ExcelHelp2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2013, 06:24 AM
  5. Runtime error 1004
    By janep in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2010, 12:31 AM
  6. Runtime error 1004
    By michael1963 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2009, 02:15 AM
  7. Runtime error 1004
    By HHHH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2006, 07:35 AM

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