Excel default sheet

Zahhhaaaa

Board Regular
Joined
Jun 29, 2011
Messages
62
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";

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?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,550
Messages
6,179,459
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top