+ Reply to Thread
Results 1 to 10 of 10

Count Named ranges VBA code

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    4

    Count Named ranges VBA code

    I want to count total named ranges in the excel workbook.

    I am using this following code but this gives me list of all the named ranges. How can I get the absolute number of named ranges rather than list.

    Sub List_All_Named_Ranges()


    Selection.ListNames

    End Sub


    I will appreciate your help..

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Count Named ranges VBA code

    This what your wanting

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Count Named ranges VBA code

    tarunpreet,

    Try:

    Please Login or Register  to view this content.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Count Named ranges VBA code

    Note that names could refer no only to ranges, but also to functions or constants. if you really want to find only the names that refer to a range above code will give the correct number onlu when there are no names referring to number or function. If there are, you can use the following

    Please Login or Register  to view this content.
    If you are pleased with a member's answer then use the Star icon to rate it.

  5. #5
    Registered User
    Join Date
    10-03-2012
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Count Named ranges VBA code

    Thanks you!!
    Last edited by tarunpreet; 10-09-2012 at 10:22 AM.

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Count Named ranges VBA code

    Hi,
    my impression was that you want only named ranges. That's why I post the code. If you want all names in the workbook the code provided by stanleydgromjr (post#3) will do the job

    Buran

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Count Named ranges VBA code

    tarunpreet,

    You are very welcome. Glad we could help.

    Come back anytime.

  8. #8
    Registered User
    Join Date
    08-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Count Named ranges VBA code

    Out of interest, it I wanted to delete all those named ranges (of functions and constants) what would the code be for that?

    Thanks

  9. #9
    Registered User
    Join Date
    08-24-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Count Named ranges VBA code

    Quote Originally Posted by buran View Post
    Note that names could refer no only to ranges, but also to functions or constants. if you really want to find only the names that refer to a range above code will give the correct number onlu when there are no names referring to number or function. If there are, you can use the following

    Please Login or Register  to view this content.
    Out of interest, it I wanted to delete all those named ranges (of functions and constants) what would the code be for that?

    Thanks

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,165

    Re: Count Named ranges VBA code

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Please start a new thread - See Forum rule #4

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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