Hello I'm trying to compare a name with worksheets that already exist to see if it has been created or not yet.
Private Sub Workbook_Open()
Dim Ldate As String
Dim Lweekday As Integer
Dim Newweek As String
Dim Sname As String
Ldate = Date
Lweekday = Weekday(Ldate)
If Lweekday = 1 Then
Newweek = DateAdd("d", 3, Ldate)
Sname = Month(Newweek) & "-" & Day(Newweek) & "-" & Year(Newweek)
Sheets.Add.Name = Sname
Application.CutCopyMode = False
Worksheets("Template").Select
Range("A1:A2").Copy
Worksheets(Sname).Select
Range("A1").PasteSpecial
Application.CutCopyMode = False
End If
End Sub
Basically I want to check if the worksheet has been created and if it has then exit the code, if not then copy and paste a template in the worksheet.
Aucun commentaire:
Enregistrer un commentaire