Delete all named ranges from worksheet

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi,

would it be possible to transform this macro to delete named ranges only from active worksheet?

Thank you.

VBA Code:
Sub DeleteNames()
Dim xName As Name
For Each xName In Application.ActiveWorkbook.Names
xName.DELETE
Next
End Sub
 
Hi,
Run these codes on a blank page. It will give you a list of your name definitions. It may be necessary to draw a path by looking at these. If you can upload a picture by making a note next to the names you want to be deleted from this list, the problem will be solved better.

VBA Code:
Sub listNameRefers()
    Dim xName As Name, sat%
    For Each xName In Application.ActiveWorkbook.Names
        sat = sat + 1
        Cells(sat, 1).Value = "'" & xName.RefersTo
    Next
End Sub
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
NB - place the code in the "ThisWorkbook" module, in your project.
Did you insert the code where I stated? I think possibly, not...
The ME in this instance, refers to ThisWorkbook, and therefore the code needs to be placed in the "ThisWorkbook" module, in your VBA project.
I know it's working, as I've tested it on my system.
 
Upvote 0
Did you insert the code where I stated? I think possibly, not...
The ME in this instance, refers to ThisWorkbook, and therefore the code needs to be placed in the "ThisWorkbook" module, in your VBA project.
I know it's working, as I've tested it on my system.
My bad.

Working perfectly now!

Thank you sykes.
 
Upvote 0
Pleasure, and thanks for the feedback.
 
Upvote 0
PS Would you be good enough to just mark post #9 as the solution, instead of #12.

Ta.
 
Upvote 0

Forum statistics

Threads
1,216,746
Messages
6,132,477
Members
449,729
Latest member
davelevnt

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