Hello, is it possible to add previous date in a sheet tab? I'm using excel 2007, and this is the code I'm using when inserting current date.
Code:
Sub UusiSivu()
ActiveWorkbook.Unprotect
Dim CurrentDay As Integer
Dim NewName As String
Dim WS As Worksheet
Set WS = ActiveSheet
If IsNumeric(Right(WS.Name, 2)) Then
CurrentDay = Right(WS.Name, 2)
ElseIf IsNumeric(Right(WS.Name, 1)) Then
CurrentDay = Right(WS.Name, 1)
Else
Exit Sub
End If
CurrentDay = CurrentDay + 1
NewName = Format(Date, "dd.mm.yyyy")
Dim checkWs As Worksheet
On Error Resume Next
Set checkWs = Worksheets(NewName)
If checkWs Is Nothing Then
'Copies the current sheet to the end of the workbook
Sheets("Default").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = NewName
Range("D2") = NewName
Dim oleObj As OLEObject
Else
Set checkWs = Nothing
MsgBox "Uusi taulukko voidaan lisätä huomenna."
End If
ActiveWorkbook.Protect
End Sub