+ Reply to Thread
Results 1 to 13 of 13

how to resolve error message

  1. #1
    Forum Contributor
    Join Date
    07-20-2007
    MS-Off Ver
    2016, 365
    Posts
    127

    how to resolve error message

    Hi All.
    I create code that generate copy of a worksheet:
    Please Login or Register  to view this content.
    It is working. But when I want to create a new sheet on the same date, in this case, the sheet will be created but an error message will pop up. How to resolve this error message?

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: how to resolve error message

    Hello. Summarizing:

    > Do you want to have two sheets with the same name?...
    Well, that's not possible: there can't be two sheets with the same name.

    > Do you want to detect that a sheet with some name already exists and name the new sheet with some variant?...
    If so, indicate what such variant would be.

  3. #3
    Forum Contributor
    Join Date
    07-20-2007
    MS-Off Ver
    2016, 365
    Posts
    127

    Re: how to resolve error message

    Hi beyond Excel. Thanks for reply.
    I know that can't be two sheets with the same name. When try to create new sheet with the same date the code generate new sheet with name, for instance, 10-19-22 (2). I will accept it. But I don't want to get pop up error message.
    How to solve that problem?

    Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: how to resolve error message

    .
    Hi. For example:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: how to resolve error message

    Unless I am missing something...
    As you are always copying active sheet the new copied sheet becomes the active sheet...So...this will work continuously numbering accordingly...
    Please Login or Register  to view this content.
    Last edited by sintek; 10-20-2022 at 01:23 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: how to resolve error message

    .
    Most likely, sintek, is that OP starts by copying a 'model' sheet and that copy is the one that needs to be renamed because it already exists in the workbook.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: how to resolve error message

    Not likely if I see his code in post1...But can only say once a reply is received...
    When try to create new sheet with the same date the code generate new sheet with name, for instance, 10-19-22 (2). I will accept it
    Code in Post 5 does this...

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: how to resolve error message

    Quote Originally Posted by sintek View Post
    ... Code in Post 5 does this...
    Let's see if i get it:

    > Select a 'template sheet' and run your macro.
    > Reselect the 'template sheet' and run your macro again.

    Do you see that it does not do what was requested?

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: how to resolve error message

    No mention of any sheet selection in first post...As the initial active sheet is just creating a copy so no need to re-select original template anyway as the new active now becomes a copy of original...User gets what they ask for...And once again as per other post...OP is not responding...so no idea of actual application...Lets leave it at that for now...
    Last edited by sintek; 10-20-2022 at 04:04 PM.

  10. #10
    Forum Contributor
    Join Date
    07-20-2007
    MS-Off Ver
    2016, 365
    Posts
    127

    Re: how to resolve error message

    Hi beyond Excel.
    I tried your code. It gives error message:
    Run-time error '1004'
    Method 'Name' of object '_Worksheet' failed


    on code line
    ws.Name = IIf(j = 0, mName, mName & " (" & j & ")")

    Thanks

  11. #11
    Forum Contributor
    Join Date
    07-20-2007
    MS-Off Ver
    2016, 365
    Posts
    127

    Re: how to resolve error message

    Hi sintek. Thanks for reply.
    I tried your code. It didn't give me an error. But can you do me a favor to explain detail code line
    Please Login or Register  to view this content.
    What is what
    Thanks

  12. #12
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: how to resolve error message

    Quote Originally Posted by eugz View Post
    Hi beyond Excel.
    I tried your code. It gives error message:

    Run-time error '1004'
    Method 'Name' of object '_Worksheet' failed


    on code line

    ws.Name = IIf(j = 0, mName, mName & " (" & j & ")")
    Could you upload a small workbook to the Forum to see your implementation of what you suggested?...
    I ask because there is no reason for the suggestion to fail.

    And another thing: do you always select the same sheet when making the copy?...

    And don't forget to make two or more copies to see how the name of your sheet changes.

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: how to resolve error message

    But can you do me a favor to explain detail code line
    It simply evaluates if sheet exists or not...But as per beyond Excel suggestion...
    Could you upload a small workbook to the Forum to see your implementation of what you suggested?...

    And another thing: do you always select the same sheet when making the copy?...

+ 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. Need help to resolve #N/A error from VLOOKUP
    By jonanth in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-21-2021, 04:44 AM
  2. how to resolve blank error
    By Merrysa in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-12-2019, 09:32 AM
  3. [SOLVED] unable to resolve error 424
    By rickmeister in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2017, 04:46 PM
  4. unable to resolve a #NUM! error message
    By Bill369 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-11-2015, 07:12 PM
  5. How can I resolve this VLOOKUP #REF error?
    By Nate Westcott in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-14-2015, 07:26 AM
  6. [SOLVED] Help to resolve Run time Error 380
    By LenaK in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2015, 11:55 AM
  7. Add ISERROR to resolve DIV/0 error
    By mtntxn in forum Excel General
    Replies: 2
    Last Post: 09-28-2009, 04:58 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