Reputation: 29
Copy function error. Wanting to copy the sheet over to a created sheet with the date indicated. What is going on?
Dim Dateini As String
Dateini = "2021-03-31"
Sheets("Sheet3").Copy After:=ActiveWorkbook.Sheets(Worksheets.Count).Name = Dateini
Upvotes: 1
Views: 490
Reputation: 54777
Option Explicit
Sub test()
Const Dateini As String = "2021-03-31"
' Use 'ThisWorkbook' if it is the workbook containing this code.
With ActiveWorkbook
.Sheets("Sheet3").Copy After:=.Sheets(.Sheets.Count)
.ActiveSheet.Name = Dateini
End With
End Sub
Upvotes: 1