Hello. I need help with my code. i'm trying to create a macro were a user clicks a button and have contents of sheet("Pick") be copied and paste values only into a new worksheet that gets created with previous date as name. Below is my code. Can't get past the error message.
Sub CommandButton1_Click()
Dim OrgWs As Worksheet
Dim szToday As String
Set OrgWs = ThisWorkbook.Worksheets("Pick")
If (WeekdayName(Weekday(Date) - 1) = "Tuesday") Then
szToday = Format(Date - 2, "mmm-dd-yy")
ElseIf (WeekdayName(Weekday(Date) - 1) = "Saturday") Then
szToday = Format(Date - 2, "mmm-dd-yy")
Else
szToday = Format(Date - 1, "mmm-dd-yy")
End If
OrgWs.Copy After:=ThisWorkbook.Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Name = szToday
End Sub
Sub CommandButton1_Click()
Dim OrgWs As Worksheet
Dim szToday As String
Set OrgWs = ThisWorkbook.Worksheets("Pick")
If (WeekdayName(Weekday(Date) - 1) = "Tuesday") Then
szToday = Format(Date - 2, "mmm-dd-yy")
ElseIf (WeekdayName(Weekday(Date) - 1) = "Saturday") Then
szToday = Format(Date - 2, "mmm-dd-yy")
Else
szToday = Format(Date - 1, "mmm-dd-yy")
End If
OrgWs.Copy After:=ThisWorkbook.Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Name = szToday
End Sub