Ok, once again I'm creating this diary, I'm almost finished it but there's still some little things needs to be done.
Could you give me an advice how to add this code;
Into this code;
so that it resets sheet into "default-mode" and also clears all cells as seen above in code.
Both of these codes work fine, but I need to put them together. I tried to do it by myself but it didn't work :P
Could you give me an advice how to add this code;
Code:
Sub NewSheet()
Sheets("Default").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(Date, "dd.mm.yyyy")
End Sub
Into this code;
Code:
Sub NewSheet()
Dim CurrentDay As Integer, NewName As String
If IsNumeric(Right(ActiveSheet.Name, 2)) Then
CurrentDay = Right(ActiveSheet.Name, 2)
ElseIf IsNumeric(Right(ActiveSheet.Name, 1)) Then
CurrentDay = Right(ActiveSheet.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
Worksheets(ActiveSheet.Name).Copy After:=Worksheets(ActiveSheet.Index)
Dim oleObj As OLEObject
With ActiveSheet
.Name = NewName
.Range("D2").ClearContents
.Range("D6").ClearContents
.Range("A31").ClearContents
.Range("B31").ClearContents
.Range("C31").ClearContents
.Range("D31").ClearContents
.Range("A34:B37").ClearContents
.Range("C34:D37").ClearContents
.Range("A40:B43").ClearContents
.Range("C40:D43").ClearContents
.Range("A46").ClearContents
.Range("B46").ClearContents
.Range("C46").ClearContents
.Range("D46").ClearContents
For Each oleObj In ActiveSheet.OLEObjects
If oleObj.progID = "Forms.TextBox.1" Then oleObj.Object.Value = ""
Next oleObj
Dim Shp As Shape
For Each Shp In ActiveSheet.Shapes
If Shp.Type = msoTextBox Then
Shp.TextFrame.Characters.Text = ""
End If
Next Shp
End With
Else
Set checkWs = Nothing
MsgBox "Uusi taulukko voidaan lisätä huomenna."
End If
End Sub
so that it resets sheet into "default-mode" and also clears all cells as seen above in code.
Both of these codes work fine, but I need to put them together. I tried to do it by myself but it didn't work :P