+ Reply to Thread
Results 1 to 4 of 4

Copying sheets with a date and a sequential number

  1. #1
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Question Copying sheets with a date and a sequential number

    In my quest to write something that would
    1.copy a template to a new sheet
    2.Rename the sheet to the current month and day (MMM-DD)
    3 Add to the date a sequencial number if another sheet were created on the same day

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    The code appears to work in isolation but but fails in two respects

    1. If only the template sheet exists in the workbook sequencial numbering begins with '1'.'MMM-DD-1'
    but if other sheets exists the numbering starts with the number of other sheets plus 1.
    I.E. if 'Template' and another sheet 'X' exists, the macro will copy the template and name it
    'MMM-DD-2 rather than 1. That sequence will continue with 2..3..etc.

    2. The other problem is that when the day changes the number sequence continues from the previous day rather
    than resetting with the new date as I would like.

    I understand the problem is that the macro is focused on the sheet number rather than the number of copies of the template on a given date, I just don't know how to address the issue.

    Thanks in advance

    Scott
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Copying sheets with a date and a sequential number

    hi there, please check attachment, press Add button
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Copying sheets with a date and a sequential number

    Thank you very much. I never would have gotten there. InStr is a new function to me.
    I looked it up and am still not quite clear on its usage but it is one to understand forsure.
    I am also confused about the usage of 'Mid' in the line:

    sName = sName & "-" & Mid(sh.Name, InStrRev(sh.Name, "-") + 1) + 1

    can you explain this to me?

    Sorry for not putting an execution button on the spreadsheet... bad form

    Again, Thank you for your help

    Scott

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Copying sheets with a date and a sequential number

    InstrRev - returns the position of an occurrence of one string within another, from the end of string.
    Syntax
    InstrRev(stringcheck, stringmatch[, start[, compare]])

    Mid function is used to return "occurence number" and increase it one up

+ 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. Replies: 10
    Last Post: 10-30-2013, 07:29 PM
  2. Copying Data to new sheets by date
    By bremen22 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-17-2013, 09:00 AM
  3. Copying a date through multiple sheets.
    By AlanWade in forum Excel General
    Replies: 3
    Last Post: 11-24-2008, 09:26 AM
  4. sequential formula copying
    By arja in forum Excel General
    Replies: 9
    Last Post: 07-06-2006, 07:15 AM
  5. Date to TEXT. NOT to sequential serial number
    By Gene in forum Excel General
    Replies: 2
    Last Post: 05-26-2006, 04:35 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