Defined Names contain autofilter ranges?

Kmanbozzy

New Member
Joined
Apr 18, 2016
Messages
18
I want to loop through all of the defined names pertaining to my sheet. That's the easy part, the issue i am encountering is that the workbook's many auto filter ranges must be stored as a defined name, which is not want i want. None of those filters were named intentionally. And the code i'm using is failing when reaching a range that's a filter. the code is commonly used i believe.
Code:
For Each nm In ActiveWorkbook.Names
on error resume next
    If nm.RefersToRange.Parent.name = ActiveSheet.name Then
            MsgBox nm.name
    End If
Next nm

Here's where it's failing. My active sheet name is ISEntry, the comparison is name of the sheet of the active defined name. it should only go to the msgbox when ISEntry = ISEntry of course, well the line nm.RefersToRange.Parent.name is failing and the resume next is there to go ahead and tell me the name that's failing. The message is "HostedPropasl!_FilterDatabase" this is telling me that the filters are being stored as defined names even though i have not intentionally defined them. How do i work around this? I ONLY want the defined names, not this filter stuff. I assume the line is failing because there is no parent name? I'm not sure.
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Untested but try
Code:
For Each nm In ActiveWorkbook.Names
On Error Resume Next
   If nm.Visible Then
      If nm.RefersToRange.Parent.Name = ActiveSheet.Name Then
         MsgBox nm.Name
      End If
   End If
Next nm
 
Upvote 0
I can't believe it was that simple. Is it true that those filter ranges are stored in the defined names? Are there any other named ranges not created by me in the name manger stored in the defined names area?
 
Upvote 0
If you use
Code:
Sub chk()
   Dim Nme As Name
   Dim Msg As String
   For Each Nme In ActiveWorkbook.Names
      Msg = Msg & vbLf & Nme.Name
   Next Nme
   MsgBox Msg
End Sub
It should show all the names in the workbook.
Alternatively use
Code:
Sub chk()
   Dim Nme As Name
   For Each Nme In ActiveWorkbook.Names
      Nme.Visible = True
   Next Nme
End Sub
And then you can see them all in the name Manager
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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