Hello,
I have a workbook with multiple sheets. I need to
Step 1: save one sheet as a new excel file;
Step 2: delete named ranges from this new saved file; and
Step 3: then delete the worksheet from the Original work book.
I have the following code which does step 1 and 3 very well.
I also have the following code for Step 2. But I am struggling to figure out where to insert this code.
I DO NOT want to remove Named Ranges from the Original Workbook, I want to remove them from the new file saved.
I have a workbook with multiple sheets. I need to
Step 1: save one sheet as a new excel file;
Step 2: delete named ranges from this new saved file; and
Step 3: then delete the worksheet from the Original work book.
I have the following code which does step 1 and 3 very well.
VBA Code:
' Step 1
' Save Current Worksheet as a new File
Application.ScreenUpdating = False
ActiveSheet.Copy
With ActiveWorkbook
.SaveAs FileName:=sFileNameXLS, FileFormat:=51
.Close SaveChanges:=False
End With
Application.ScreenUpdating = True
'Step 3
' Delete the Temp Sheet
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
I also have the following code for Step 2. But I am struggling to figure out where to insert this code.
I DO NOT want to remove Named Ranges from the Original Workbook, I want to remove them from the new file saved.
VBA Code:
'Step 3
' Remove all Names
' Dim MyName As Name
' For Each MyName In Names
' ActiveWorkbook.Names(MyName.Name).Delete
' Next: