+ Reply to Thread
Results 1 to 8 of 8

Thisworkbook.names.count shows one extra range

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Thisworkbook.names.count shows one extra range

    Hi

    In the attached workbook. I have only thirty named ranges Also shown Sheet1. But in the immediate window the answer of ?ThisworkBook.Names.counts shows 31.Are all the named ranges weather created from the named manager or by selecting a range ,typing a name in Namebox on top of A1 and hitting Enter, are shown in the name Manger (I don't remember I create a named range with the later method).

    Thanks in advance


    Best Regards
    Imran Bhatti
    Attached Files Attached Files
    Last edited by ImranBhatti; 12-13-2017 at 12:29 PM. Reason: Attachment was left
    Teach me Excel VBA

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Thisworkbook.names.count shows one extra range

    Likely a hidden/invisible named range.

    Ill take a peak at the file

    EDIT: your hidden name is called "Notes!_FilterDatabase". You can try deleting it via VBA if its not needed.

    EDIT2: I was able to delete it via VBA. I looped the names collection and put an If n.name = "Notes!_FilterDatabase" then followed by an n.delete. In this case I declared n as a name earlier in the code and used a for loop to loop each n in Names.
    Last edited by Zer0Cool; 12-13-2017 at 12:39 PM.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Contributor
    Join Date
    07-11-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    144

    Re: Thisworkbook.names.count shows one extra range

    Hi ImranBhatti,

    The reason for extra name range is due to 'Notes!_FilterDatabase'.

    Please Login or Register  to view this content.
    Use this code to view all the names in a workbook.
    Last edited by fshbet; 12-13-2017 at 12:53 PM.
    Ravikumar,

    * Please Add Reputation if solved.

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Thisworkbook.names.count shows one extra range

    Thanks both of you.
    I did received this file from the dropbox of one of my client. Can you please tell or even better direct me to some resource about this problem.
    I think this is something that can be manipulated other ways.


    Thanks again.

    Best Regards
    Imran Bhatti

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Thisworkbook.names.count shows one extra range

    It is a name that is created automatically by Excel when applying filters to a range. Why does it matter to your code?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Thisworkbook.names.count shows one extra range

    Thanks xlnitwit

    The reason it matters is because I need to use the count of NamedRanges in the code. Is confirmed that filtering data will create only one named range. coz at the moment Or repharase the question . will the filter create the named range always with this name (Mysheetname_FilterDatabase). I think I should mark my thread Unsolved.

    Problem is solved but only for this book and not generally. It does not mean by any mean that the solution by fshbet and zerocool is not appreciated.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Thisworkbook.names.count shows one extra range

    My question is why does it matter? It would be extremely time consuming to write code to eliminate every possible unexpected name. If you are only interested in specific names, do they have an attribute that you can check- for example, are you only interested in visible names? If so, simply test the Visible property inside your loop before doing anything with the Name.

  8. #8
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Thisworkbook.names.count shows one extra range

    Well pointed xlnitwit .It solved my problem now really.
    ?thisworkbook.Names(i).Visible

    Never needed to check this property of named range before.

    Many thanks indeed.

+ 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. ThisWorkbook.VBProject.References.Count not working
    By Mike1001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2017, 07:24 AM
  2. [SOLVED] List in dynamic combobox which shows open workbook names and workshee names
    By igormigor in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2016, 06:09 AM
  3. Vba count continuous names in a range
    By Konexcelmath in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-01-2014, 06:19 PM
  4. Replies: 5
    Last Post: 09-04-2012, 09:59 AM
  5. Replies: 3
    Last Post: 07-10-2012, 05:29 AM
  6. Vba ThisWorkbook.Names unsorted column
    By Ed Burn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-26-2009, 05:05 PM
  7. How to get rid of extra ThisWorkbook
    By Kirtc in forum Excel General
    Replies: 1
    Last Post: 03-15-2007, 12:24 PM

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