Macro suddenly stopped working in Excel 365

jupasto

New Member
Joined
Aug 19, 2019
Messages
9
Hello,

I created this macro over a year ago in Excel 365 and it worked up until very recently (also it still works perfectly in Excel 2019). When run it's supposed to copy the "Add New Worksheet" button into the new worksheet it creates however in no longer copies the button (see pictures). I'm an novice with VBA and I was wondering if anyone knows how to fix this so it will copy the button when the file is opened in Excel 265. Thanks.

VBA Code:
Sub AddSheets_TodayDate()
'Updateby20140717
    Dim szTodayDate As String
    szTodayDate = Format(Date, "mmmmdd")
    On Error GoTo MakeSheet
    Sheets(szTodayDate).Activate
    Exit Sub
MakeSheet:
    Sheets.Add , Worksheets(Worksheets.Count)
    ActiveSheet.Name = szTodayDate
 
    Sheets("October02").Range("A1:Z100").Copy Destination:=Worksheets(Worksheets.Count).Range("A1")
    
   Sheets("October02").Select
    Cells.Select
    Selection.Copy
    Range("C13").Select
    Sheets(Worksheets.Count).Select
    Cells.Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    
    Range("C4:F100").Select
    Selection.ClearContents
    Range("R4").Select
    Selection.ClearContents
     Range("H4:O100").Select
    Selection.ClearContents
    
    ActiveSheet.Protect "toby", True, True
    
     Rows("4:4").Select
    ActiveWindow.FreezePanes = True
    
End Sub
 

Attachments

  • existing worksheet with button(1).jpg
    existing worksheet with button(1).jpg
    163.5 KB · Views: 9
  • new worksheet created without button(1).jpg
    new worksheet created without button(1).jpg
    151.9 KB · Views: 9

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Why not actually copy the worksheet instead of creating a new, blank worksheet and then copying the contents over?
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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