VBA code to delete workbook scope name

ceytl

Board Regular
Joined
Jun 6, 2009
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
My workbook and worksheet has the same scope name.

The workbook ref is broken, so I would like to delete it.

The top name is the worksheet scope, and the bottom name is the workbook scope:

1642576769378.png


I have used: ActiveWorkbook.Names("ShipMonth").Delete ...but it delete's the sheet scope name first, and I need it to delete the workbook scope.

Any ideas?

Thanks!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You need to make sure that the active sheet is not the sheet to which the sheet named range is scoped.
If you are on the sheet to which the named range is scoped it takes precedence over the workbook named range when you access it, whether that be to use it or delete it.

So if ShipMonth is scoped to Sheet1, you need to be on any sheet other than Sheet1 to delete the workbook version of ShipMonth.
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

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