+ Reply to Thread
Results 1 to 8 of 8

Add prefix to re-name sheet

  1. #1
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Smile Add prefix to re-name sheet

    This code works fine for naming a new sheet with todays date and increment but does anyone know how to prefix it with something?
    For example: instead of "01-31-11-(1)" it would re-name to "Sail-01-31-11-(1)" then "Sail-01-31-11-(2)" and so on.


    Please Login or Register  to view this content.
    Last edited by Mayweed; 01-31-2011 at 06:28 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add prefix to re-name sheet

    Hi Mayweed

    You could try
    Please Login or Register  to view this content.
    Not tested.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Add prefix to re-name sheet (Attached)

    John,
    Thanks for your reply, I've already tried that solution but it only works one time: run the macro twice and it throws an error.
    The attached sheet shows macro1 working fine with multiple hits and macro2 failing after only one.
    Any ideas?
    Attached Files Attached Files
    Last edited by Mayweed; 01-31-2011 at 05:46 AM. Reason: Modified title to denote attached file

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Add prefix to re-name sheet

    I'm not clear what you want.

    Basically your code currently loops through each sheet & checks the name, increasing x if any sheets match the criteria.

    It then selects Boat & copies it whilst renaming it with Sail and x added.

    When a macro ends the variables are removed from memory, so next time that you run it then it start with x as zero
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Add prefix to re-name sheet

    I think this might be what you want
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Add prefix to re-name sheet

    I'm trying to copy the boat sheet and then rename it with today's date, any further copies would be incremented by 1. This seems to be working fine with macro1 but I cant figure out how to prefix the new sheet name with anything.
    In short... Run macro1 a few times and the resulting sheets should be named Sail-01-31-11 (1), Sail-01-31-11 (2), and so on.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Add prefix to re-name sheet

    Try the example code

  8. #8
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Re: Add prefix to re-name sheet

    That's exactly what I wanted it to do, thanks Roy.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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