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?
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