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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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
PS Would you be good enough to just mark post #9 as the solution, instead of #12.

Ta.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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