Results 1 to 11 of 11

Copy Sheet named as current date with button VBA Excel

Threaded View

  1. #1
    Registered User
    Join Date
    06-10-2021
    Location
    romania
    MS-Off Ver
    2013
    Posts
    5

    Unhappy Copy Sheet named as current date with button VBA Excel

    I am trying to copy the first sheet once/click and name it automatically as current date.

    first click is adding 2 sheets (10-Jun-21 & 10-Jun-21 (2));
    Second click is adding Operator(2) & 10-Jun-21 (3);
    third click is adding Operator(3) & 10-Jun-21(4);
    When i click the button 4th time is adding one sheet per click (10-Jun-21(5)).
    I don't understand why after the 4th click does what i want it to do. Here is my code. Thank you!!!

    Private Sub CommandButton1_Click()
    
    Dim I As Long
    Dim szTodayDate As String
        szTodayDate = Format(Date, "mmm-dd-yyyy")
        On Error Resume Next
    
    Sheets("Operator").Copy After:=Worksheets(Worksheets.Count)
    Do
    ActiveSheet.Name = szTodayDate
        Sheets(szTodayDate).Copy After:=Worksheets(Worksheets.Count)
        ActiveSheet.Name = szTodayDate
    
    Loop While ActiveSheet.Name = szTodayDate
    
    End Sub
    Last edited by AliceIoana; 06-10-2021 at 08:48 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Button to open up existing excel file in another sheet in current excel workbook
    By bearcats667 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2018, 02:58 PM
  2. [SOLVED] Button to copy the current cell into the next blank cell of another sheet
    By Smeghead in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-23-2015, 08:38 AM
  3. Replies: 4
    Last Post: 08-16-2013, 04:10 AM
  4. command button 1 (save as pdf named the current time and date . then send by email
    By guitarist00 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-02-2013, 09:43 AM
  5. Using VBA button to "Save as", add current date & copy cell data.
    By Pedro1803 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2011, 07:56 PM
  6. Copy a sheet into a new book and save file name as the current date.
    By Jay3 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-10-2009, 06:59 AM
  7. Command button - to copy active sheet and not save current workbook
    By vjboaz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2008, 05:23 PM

Tags for this Thread

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