Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:06:39+00:00 2026-06-02T16:06:39+00:00

I am using the following code: Dim rng As Range Set rng = Workbooks(import

  • 0

I am using the following code:

Dim rng As Range

Set rng = Workbooks("import sheet.xls").Sheets("import").Range("project_name,project_author,project_code,project_breaker,default_fault_ac_mcb,default_fault_ac_mccb,default_fault_dc,default_fault_acb,default_rvdrop,default_svdrop,default_eff,default_pfactor,default_ratio,default_freq,default_sfactor_ac,default_spfactor")

For Each cell In rng.Cells
    MsgBox cell
Next cell

Now project_name, project_author, etc. are different named ranges in the sheet. The problem is when I add another named range to the above list (already defined), I get a runtime error 1004 (“select method of range class failed”).

Is there a limit to the number of named ranges one can add to range object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:06:40+00:00Added an answer on June 2, 2026 at 4:06 pm

    I couldn’t find anything on why this happens but I am still looking.

    However this works. You can combine the range using UNION

    Sub Sample()
        Dim rng As Range, cell As Range, newRng As Range
    
        Set rng = Sheets("import").Range("project_name,project_author,project_code,project_breaker,default_fault_ac_mcb,default_fault_ac_mccb,default_fault_dc,default_fault_acb,default_rvdrop,default_svdrop,default_eff,default_pfactor,default_ratio,default_freq,default_sfactor_ac,default_spfactor")
    
        Set newRng = Union(rng, Sheets("import").Range("default_sid"))
    
        For Each cell In newRng.Cells
            MsgBox cell
        Next cell
    End Sub
    

    UPDATE: I couldn’t find any Microsoft document which describes this behavior, but after some experimentation, I can confirm that the maximum number of named ranges one can add to range object is 16. This behavior can be seen in in Excel 2003, 2007, and 2010.

    Strangely this behavior was not replicated in Excel 2011 (MAC). I tested with 19 names and it worked.

    MORE UPDATE

    After more testing, I discovered that if you name your ranges as Name1, Name2, Name3 etc then I was able to add more named Ranges in Excel 2003-2007-2010. So it has to do something with the naming of the names.

    I have filed a bug with Microsoft.

    SAMPLE FILE FOR TESTING:

    https://skydrive.live.com/redir.aspx?cid=cdd3f8abe20bbe3b&resid=CDD3F8ABE20BBE3B!157&parid=CDD3F8ABE20BBE3B!150&authkey=!ADP_QVBopsqenBA

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to call a batch file: dim shell set
Hey I am currently using the following code Dim flickr As New Flickr(apikey) Dim
I'm currently downloading an HTML page, using the following code: Try Dim req As
Using the following code: Private Sub MakeMeSomeXmlBeforeRyanGetsAngry() Dim db As New MyDBDataContext Dim customer
I'm using the following code to dragdrop data from listbox into another applications: Dim
I am using the following code to backup my database... Dim con As SqlConnection
I created a DB using following code. Dim conn As New SqlConnection(Server=.\SQLExpress;Data Source=;Integrated Security=SSPI)
Please see the pic. I am attaching DBs using following code. Dim conn As
Using the following code here Sub FooSub Dim db As New FooDataContext Dim u
Using the following code: <% Option Explicit Response.Buffer = True Dim videoVimeo : videoVimeo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.