+ Reply to Thread
Results 1 to 10 of 10

Error to retrieve range associated with "named range"

  1. #1
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Error to retrieve range associated with "named range"

    Hello to all,

    I have and named range called "Colors" associated with range "Sheet2!$B1:$B4" and I get error
    "Run-time1004: Application-defined or Object-defined error" when I use this code to get the range
    associated.
    Please Login or Register  to view this content.
    May somebody help me to fix this please. I'm attaching a sample file.

    Regards
    Attached Files Attached Files

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Error to retrieve range associated with "named range"

    If all you're trying to do is assign the Color range to a variable then
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error to retrieve range associated with "named range"

    When assigning Objects to variables, one should use the keyword Set.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Error to retrieve range associated with "named range"

    Hello tinbendr and mikerickson,

    I've tried both options and continue getting the same error 1004.

    Please Login or Register  to view this content.
    I don't know what happen. Do these 2 options work for you with my sample file attached in first porst?

    Regards

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error to retrieve range associated with "named range"

    When Set is added, that code works fine for me.

  6. #6
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Error to retrieve range associated with "named range"

    Uhh, it's strange. I'm using MS Excel 2010 under Windows 7.

    Do you know if this should work depends on enabling some library in Excel Advanced options?

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error to retrieve range associated with "named range"

    I'm using Excel 2011.

    What does this return for you?
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Error to retrieve range associated with "named range"

    as per help in Excel 2007(I assume it is the same story for Excel 2010) for Name.RefersToRange Property:

    Remarks
    If the Name object doesn't refer to a range (for example, if it refers to a constant or a formula), this property fails.

    Si it looks Excel versions after 2010 can evaluate the formula and produce the range object

  9. #9
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Error to retrieve range associated with "named range"

    Both examples work on my Office 2013.

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error to retrieve range associated with "named range"

    When you run that code, what is the string that the computer returns on the OP machine?

+ 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. How to use named ranges in VBA code using "Columns" and a variation on "Range"
    By haljam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2014, 02:48 PM
  2. Getting "..object _worksheet failed..." error with intersect for cell and named range.
    By cool1_boy1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 04:17 PM
  3. [SOLVED] Macro Sheet Protect Error Due to This Sub NextScreening() Range("C2").Value = Range("C
    By cychua in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-29-2012, 04:51 AM
  4. Syntax error on trying to create a "Named range"
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2011, 03:40 PM
  5. Replies: 3
    Last Post: 06-04-2011, 10:56 AM

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