+ Reply to Thread
Results 1 to 10 of 10

Function fails when computed reference is only one row.

  1. #1
    Forum Contributor
    Join Date
    06-12-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    132

    Function fails when computed reference is only one row.

    The following function fails when a reference calculates to one row. =INDIRECT("$A"&MATCH(FALSE,INDEX(ISBLANK(INDIRECT("$A"&SUM(ROW())&":$A"&LOOKUP(2,1/(INDIRECT("$A$1:$A"&(SUM(ROW())))<>""),ROW($A$1:$A$3000)))),),0)+(SUM(ROW()))-1)

    It works fine if I simply add "+1" to the calculated row. Works =INDIRECT("$A"&MATCH(FALSE,INDEX(ISBLANK(INDIRECT("$A"&SUM(ROW())&":$A"&LOOKUP(2,1/(INDIRECT("$A$1:$A"&(SUM(ROW())+1))<>""),ROW($A$1:$A$3000)))),),0)+(SUM(ROW()))-1)

    Can someone explain why? How do I fix this? Thanks!

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Function fails when computed reference is only one row.

    The first one evaluates to =A1. The second one evaluates to = A2. It seem a rather complicated way of doing things. Please post a sample sheet (see yellow banner) showing what you are trying to do!!!

    INDIRECT and whole column references are an EXTREMELY bad idea. They are very inefficient.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    06-12-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    132

    Re: Function fails when computed reference is only one row.

    Quote Originally Posted by Glenn Kennedy View Post
    The first one evaluates to =A1. The second one evaluates to = A2. It seem a rather complicated way of doing things. Please post a sample sheet (see yellow banner) showing what you are trying to do!!!

    INDIRECT and whole column references are an EXTREMELY bad idea. They are very inefficient.
    Added workbook.
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Function fails when computed reference is only one row.

    You still didn't tell me what you want the formula to do!! At a guess, you want a blank-free list. This is a FAR better way to get one:

    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$1000)/($A$2:$A$1000<>""),ROWS(E$2:E2))),"")

    copied down.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    06-12-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    132

    Re: Function fails when computed reference is only one row.

    Quote Originally Posted by Glenn Kennedy View Post
    You still didn't tell me what you want the formula to do!! At a guess, you want a blank-free list. This is a FAR better way to get one:

    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$1000)/($A$2:$A$1000<>""),ROWS(E$2:E2))),"")

    copied down.
    Sorry about that. The formula finds the address of the first cell that is not empty and then returns the contents of that cell. When the range that is fed to MATCH is just one cell (i.e. range is for example A2:A2 but gets changed to just A2), it fails. However when the range is more than one cell it works fine. The second formula in my original post where I added "+1" was to test this theory. It has to have a range of 2 cells or more to work. Why? Is there a fix?

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Function fails when computed reference is only one row.

    So, if you want to return the first non-blank cell in a range forget the big, unwieldy formula of yours...

    =LOOKUP(2,1/(A1:A3000<>""),A1:A3000)

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Function fails when computed reference is only one row.

    Senior moment (all too common these days!!):

    =VLOOKUP("*",A:A,1,FALSE)

  8. #8
    Forum Contributor
    Join Date
    06-12-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    132

    Re: Function fails when computed reference is only one row.

    Quote Originally Posted by Glenn Kennedy View Post
    So, if you want to return the first non-blank cell in a range forget the big, unwieldy formula of yours...

    =LOOKUP(2,1/(A1:A3000<>""),A1:A3000)
    Thanks but that returns the last row number not the first contents. Do you have a theory as to why that part of the formula fails with a one cell range?

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Function fails when computed reference is only one row.

    See Post 7!!

  10. #10
    Forum Contributor
    Join Date
    06-12-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    132

    Re: Function fails when computed reference is only one row.

    I found an explanation for this behavior which is here. https://stackoverflow.com/questions/...gle-cell-range. Can someone explain what IF({1},RANGE) is doing? Particularly the 1 in the braces. Why does this work?
    Last edited by bird333; 07-19-2021 at 09:04 PM.

+ 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. End Sub if a Call Function fails
    By ethelbertmagnus in forum Excel General
    Replies: 3
    Last Post: 06-17-2021, 02:10 AM
  2. [SOLVED] Cell Reference fails because pasted data is variable length
    By JeffGrant in forum Excel Formulas & Functions
    Replies: 29
    Last Post: 03-23-2021, 05:21 AM
  3. 3-D reference fails
    By Ericng in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 01-07-2016, 08:04 AM
  4. [SOLVED] Function Fails to work
    By Inti in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 06-20-2014, 12:25 AM
  5. =RIGHT Function Fails with Numbers
    By billtreloar in forum Excel Formulas & Functions
    Replies: 24
    Last Post: 11-08-2013, 02:19 PM
  6. [SOLVED] Unusual #N/A error - One cell reference works, another fails!
    By mhroberts in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-09-2013, 12:40 AM
  7. DAY-Function fails
    By johntrav2004 in forum Excel General
    Replies: 11
    Last Post: 01-03-2011, 07:19 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