+ Reply to Thread
Results 1 to 3 of 3

Named Range count in immediate window is incorrect, please help :)

Hybrid View

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    Named Range count in immediate window is incorrect, please help :)

    Hello

    This is starting to drive me a little bit mad, I hope someone can help!

    In a model I'm developing I have a tab that lists all of the named ranges in the workbook, using the
    listnames
    VBA method. So far so good, works absolutely fine and gives me a list of 158 names.

    However, if I count the names in the Immediate window using
    ActiveWorkbook.Names.Count
    I get 160...

    I've even manually counted all of the names in the Name Manager and got 158, so I cannot understand where the extra 2 are coming from!

    Has this happened for anyone else? Does anyone know why it's occurring or how to fix it?

    Thanks all
    Kenny

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Named Range count in immediate window is incorrect, please help :)

    These snippets may help you
    Sub Loop_Through_Each_Named_Range()
        Dim nm      As Name
    
        For Each nm In ActiveWorkbook.Names
            Debug.Print nm.Name & " : " & nm.RefersTo
        Next nm
    End Sub
    
    Sub Hide_All_Named_Ranges()
        Dim objName         As Name
        
        If Not Application.ActiveWorkbook Is Nothing Then
            For Each objName In Application.ActiveWorkbook.Names
                objName.Visible = False
            Next objName
        End If
    End Sub
    
    Sub Unhide_All_Named_Ranges()
        Dim objName         As Name
        
        If Not Application.ActiveWorkbook Is Nothing Then
            For Each objName In Application.ActiveWorkbook.Names
                objName.Visible = True
            Next objName
        End If
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,353

    Re: Named Range count in immediate window is incorrect, please help :)

    With the code that YasserKhalil has provided, you will see that there are hidden Named Ranges. Some examples: _xlfn.FORMULATEXT, _xlfn.IFERROR.

    I think there may be other hidden entriesbut I don't recall what they are. Maybe something to do with Databases ...
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Count number of elements in named range
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-23-2018, 06:28 AM
  2. [SOLVED] How to Count Values Which Are Between 100 and 200 Without Creating Named Range
    By zanshin777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-25-2015, 10:03 AM
  3. [SOLVED] Count items not included in a data validation range sourced from named range
    By L plates in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-10-2015, 01:05 PM
  4. [SOLVED] For...Next loop - trying to have named range increase by count of 1
    By seaveegee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 02:06 PM
  5. Count Cells in Named Range
    By yawnzzzz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2011, 02:37 PM
  6. Count of Dynamic Named Range with more criteria
    By Wermeael in forum Excel General
    Replies: 3
    Last Post: 08-29-2010, 02:42 PM
  7. [SOLVED] Count formula within a named range.
    By PW11111 in forum Excel General
    Replies: 2
    Last Post: 07-19-2005, 05:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1