Named Ranges - Remove when saving ?

Sparkle99

Board Regular
Joined
May 22, 2009
Messages
119
Hi,
I have an Excel 2007 XLSM workbook that processes a worksheet and then copies it and saves it as a new file.
All fine.

The main workbook makes use of a lot of named ranges.

When the new file is then sent to a different PC and opened and saved, there's a warning about formulas are linked to ranges in other workbooks - the name manager in the new workbook shows the named ranges from the originating workbook.

So, when I save the new XLSX file, can I remove the named ranges so that this warning doesn't occur ? (as the ranges are not required in the new workbook)
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
The below code will remove all names from the active workbook...

Code:
Sub Del_Names()
Dim nm As Name
Dim i As Long, Count As Long
i = 1
Count = ActiveWorkbook.Names.Count
On Error Resume Next
For Each nm In ActiveWorkbook.Names
    nm.Delete
    Application.StatusBar = "Deleting " & i & " of " & Count & " Names..."
    i = i + 1
Next nm
Application.StatusBar = False
End Sub
 
Upvote 0
Thanks, this works a treat.
I've slimmed it down to...

Dim NameRange As Name
For Each NameRange In ActiveWorkbook.Names
NameRange.Delete
Next NameRange
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

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