Copy sheet, values only, naming with today's date

CatieBear93

New Member
Joined
Nov 30, 2021
Messages
3
Office Version
  1. 2021
  2. 2010
Platform
  1. Windows
I am trying to copy an entire sheet, pasting only the values and renaming the new sheet to the current date.
This code allows me to input the date manually, but it copies formatting and the formulas too.

Sub AddNameNewSheet1()
Dim Newname As String
Newname = InputBox("Name for new worksheet?")
If Newname <> "" Then
Sheets.Add Type:=xlWorksheet
ActiveSheet.Name = Newname
End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
UPDATE:
I was able to get the code to automatically name it the current date, however it is still copying over the formatting

VBA Code:
Sub CopySheet_TodayDate()
'Updateby20140717
    Dim newName As String
    Dim szTodayDate As String
    szTodayDate = Format(Date, "mmm-dd-yyyy")
    
    On Error Resume Next
    newName = szTodayDate

    If newName <> "" Then
        ActiveSheet.Copy After:=Worksheets(Sheets.Count)
        On Error Resume Next
        ActiveSheet.Name = newName
    End If
End Sub
 
Upvote 0
Hi & welcome to MrExcel.

How about ...
VBA Code:
Sub CatieBear93()
    With ActiveSheet
        .Cells.Copy
        With .Parent.Sheets.Add
            .Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            .Range("A1").Select
            .Name = VBA.Format$(VBA.Date$, "mmm-dd-yyyy")
        End With
    End With
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Solution
Hi & welcome to MrExcel.

How about ...
VBA Code:
Sub CatieBear93()
    With ActiveSheet
        .Cells.Copy
        With .Parent.Sheets.Add
            .Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            .Range("A1").Select
            .Name = VBA.Format$(VBA.Date$, "mmm-dd-yyyy")
        End With
    End With
    Application.CutCopyMode = False
End Sub
This worked! Thank you for your help.
 
Upvote 0
You are welcome and thanks for the feedback (y)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top