Hello,
I have a worksheet that has a name based on specific date. I'm using this code to open new sheet, attached to commandbutton "New";
Then, I have a code that adds more rows in the sheet, attached to commandbutton "Insert row";
Is it possible that when I add more rows in one sheet (11.11.2011), then select "New", so that it opens a new sheet (11.12.2011), is it possible to have some kind of code that this new sheet has erased all rows I added in previous sheet (11.11.2011) ??
Like this;
11.11.2011
I insert 15 rows
--> NEW
11.12.2011
(all rows I added 11.11.2011 have been erased, and I can add more or less rows to this date?)
I insert 10 rows
--> NEW
11.13.2011
(every row I added 11.12.2011 have been erased, etc.etc.etc.)
Is it possible?
I have a worksheet that has a name based on specific date. I'm using this code to open new sheet, attached to commandbutton "New";
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
Then, I have a code that adds more rows in the sheet, attached to commandbutton "Insert row";
Code:
Sub insertrow()
With Rows(6)
.Copy
.Insert 'the copy will be put in the newl;y created row
End With
Application.CutCopyMode = False
End Sub
Is it possible that when I add more rows in one sheet (11.11.2011), then select "New", so that it opens a new sheet (11.12.2011), is it possible to have some kind of code that this new sheet has erased all rows I added in previous sheet (11.11.2011) ??
Like this;
11.11.2011
I insert 15 rows
--> NEW
11.12.2011
(all rows I added 11.11.2011 have been erased, and I can add more or less rows to this date?)
I insert 10 rows
--> NEW
11.13.2011
(every row I added 11.12.2011 have been erased, etc.etc.etc.)
Is it possible?