+ Reply to Thread
Results 1 to 3 of 3

Index outside named range does not result in error?!

  1. #1
    Registered User
    Join Date
    09-06-2011
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    1

    Index outside named range does not result in error?!

    Dear all,

    I make use of a large number of named ranges which I define and use in my vba code.

    The strange thing is that when select an index from the range which is outside the range it doesn't present an error. Instead it selects the first cell in the next row.

    Example:

    Named_Range A1:A3
    Named_Range.Cells(1) = A1
    Named_Range.Cells(2) = A2
    Named_Range.Cells(3) = A3
    Named_Range.Cells(4) = B1 ?!

    Does anybody know why this happens and how to prevent it from happening?

    Thanks a bunch.

    Sander

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Index outside named range does not result in error?!

    Did a test on Excel 2010 and it works properly. It does not return an error but the value returned is EMPTY.
    Can't help about 2007, sorry.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Index outside named range does not result in error?!

    The Cells property will refer to cells starting from the specified cell or range - or the first cell of a multiple cell range. It is not limited to only cells within the range unless you are using a For Each loop.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

+ 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. Help using named range with index function
    By mpjennings25 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-08-2013, 03:48 PM
  2. Lookup using the result of a function as a named range
    By hinkle.j.s in forum Excel General
    Replies: 5
    Last Post: 01-18-2011, 12:42 PM
  3. Subtotal with Named Range, result not showing
    By matt4003 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-07-2010, 01:13 PM
  4. Using INDEX with named range reference
    By engmeee in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 11-19-2008, 06:21 PM
  5. Defining a named range for a dynamic result set
    By Keith B. in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2006, 05:30 PM

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