+ Reply to Thread
Results 1 to 15 of 15

Duplicator Code Gives Wrong Sheet Name

  1. #1
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Duplicator Code Gives Wrong Sheet Name

    Hello,

    I have this duplicator code that for some reason the last sheet copied name in the index of the Admin sheet is "CopySheet (2)" but it should be named the last Job.

    This is activated on the Admin sheet by first selecting the number of copies then click the shape "Add New Job Sheets".


    Can someone please see why?

    Thank you for your help

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Duplicator Code Gives Wrong Sheet Name

    Code worked fine on my machine.
    If I were to guess...
    Though highly unlikely, it's ActiveSheet.Name that misfired. As in, it was executed before copied sheet became active.
    Or the code terminated right after Sheets().Copy...

    But hard to say. May be replace ActiveSheet.Name line to...
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    Thanks but it is still doing the same thing. Did you look at the Admin sheet to see the sheet names? The last one is named 'CopySheet (2)' yet the associated tab has the correct Job name.

  4. #4
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    I was able to solve issue:

    I changed the ListSheets formula to:

    =REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")&T(NOW())

    And put this in This Workbook code:

    Please Login or Register  to view this content.

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

    Re: Duplicator Code Gives Wrong Sheet Name

    Different approach.
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Duplicator Code Gives Wrong Sheet Name

    Ah so the issue wasn’t the code. I was only looking at the issue in the code.

  7. #7
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    I wasn't sure where the issue was. I found someone with a similar issue and adapted to my workbook. So far it is working better.

  8. #8
    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,446

    Re: Duplicator Code Gives Wrong Sheet Name

    Not entirely sure where your sheet list is but, given you are using VBA anyway, youu could use something like this:

    Please Login or Register  to view this content.
    You might not then need to complicate the sheet(s) with Excel 4 Macros. Just a thought.
    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


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

    Re: Duplicator Code Gives Wrong Sheet Name

    Have you tried the code from Post #5 at all?

  10. #10
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    @jolivanes yes I tried it but it only gives me one copy. I would like it to copy the number of times that are in cell K4 of the Admin sheet please.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,838

    Re: Duplicator Code Gives Wrong Sheet Name

    Is this solved? If not, please remove the SOLVED tag!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  12. #12
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    It is solved but jolivanes asked if I tried his code.

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

    Re: Duplicator Code Gives Wrong Sheet Name

    Not very sophisticated but easy to follow and change if required.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    02-26-2023
    Location
    Lousianna
    MS-Off Ver
    Microsoft 365
    Posts
    932

    Re: Duplicator Code Gives Wrong Sheet Name

    Thank you @jolinvanes.

    Your code works great!

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

    Re: Duplicator Code Gives Wrong Sheet Name

    Thanks for the update and good luck

+ 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] Edit Duplicator Code to Add More Job Sheets
    By billy60 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2023, 09:45 AM
  2. [SOLVED] Format Sheet Name in Duplicator
    By billy60 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-14-2023, 03:06 PM
  3. [SOLVED] code is deleting the wrong sheet rows
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2023, 04:31 AM
  4. [SOLVED] Code running on wrong sheet.
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-14-2015, 04:59 PM
  5. Code working but on wrong sheet
    By pauldaddyadams in forum Excel General
    Replies: 6
    Last Post: 11-11-2011, 07:29 AM
  6. Code running in wrong sheet
    By cgeistman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-01-2008, 03:39 AM
  7. [SOLVED] Processing code on wrong sheet
    By Jeff Klein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2005, 03: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