vba - delete sheets in activeworkbook

honger

New Member
Joined
Dec 12, 2013
Messages
22
I am working on a macro which creates a new workbook by copying activeworkbook and while doing so delete some sheets.
For some reason, i can see that it deletes it, but then it creates it again. In question is highlighted in red font. Can someone point to me what i am doing wrong?
Code:
 some Codes to create new workbook then comes below
'name new WB
    Set newWBK = Workbooks.Open(vpath1 & vpath2 & ".xlsm")
'Make the new workbook active
    newWBK.Activate
    
[COLOR="#FF0000"]Application.DisplayAlerts = False
If ComboBox3.Value = "Master" Then Sheet7.Delete
Application.DisplayAlerts = True[/COLOR]
ActiveSheet.Range("Q1").Value = MyProduct
ActiveSheet.Range("R1").Value = MyApplication
ActiveSheet.Range("S1").Value = MySCN
ActiveSheet.Range("T1").Value = MyEvent

FriendlyName1 = "Link to Documents with SCN"
MyPath1 = "[URL]https://tarregsp01p/sites/Regulatory/NextDocs%20Document%20Library/Forms/Detailed%20View.aspx?View={0C67A7C1-5BDA-4B11-A42D-4064D61BF7EC}&FilterField1=SCNNumber&FilterValue1[/URL]=" & MySCN
FriendlyName1 = "Link to RegApp with product"
MyPath2 = "[URL]https://tarregsp01p/sites/Regulatory/_layouts/FormServer.aspx?XmlLocation=/sites/Regulatory/RegApp/Submission/Submission[/URL]-" & MyProduct & "-" & MySCN & ".xml&DefaultItemOpen=1"

ActiveSheet.Range("A1").Formula = "=Hyperlink(""" & MyPath1 & """, """ & "Link to Documents with - " & MySCN & """)"
ActiveSheet.Range("C1").Formula = "=Hyperlink(""" & MyPath2 & """, """ & "Link to RegApp for - " & MySCN & " " & MyEvent & """)"
With Range("a1").Font
    .Bold = True
End With
With Range("c1").Font
    .Bold = True
End With
    
newWBK.Save
newWBK.Activate
'Close the template without saving
ThisWorkbook.Close False

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,216,207
Messages
6,129,503
Members
449,512
Latest member
Wabd

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