+ Reply to Thread
Results 1 to 14 of 14

R0W() gives error in complex functions

  1. #1
    Registered User
    Join Date
    05-20-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    8

    R0W() gives error in complex functions

    When i use the following function everything goes fine:

    =INDIRECT(ADDRESS(ROW();12;4))

    But when I use the following function, it gives an error:

    =MATCH(1;('Mysheet'!L:L=INDIRECT(ADDRESS(ROW();12;4)))*1;0)

    And when I change it to the following it goes fine:

    =MATCH(1;('Mysheet'!L:L=INDIRECT(ADDRESS(112;12;4)))*1;0)


    Why does ROW() work in the first function and not in the second, although the second is correct as it is working in function 3...



    Thank you

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    When you enter the formula with CTRL + SHIFT + ENTER
    It is processed as an array.
    The Row() function (in an array formula) will return an array result {112}
    Indirect can't process that array result, and returns #Value! error

    The first formula works because it's not an array formula entered with CSE.
    So the Row function just returns the number 112, (NOT as {112})

    Use the formula evaluation tool and see the difference in the result of the row() function between the two formulas.


    To resolve, try the rowS function instead.
    =MATCH(1;('Mysheet'!L:L=INDIRECT(ADDRESS(ROWS($A$1:$A112);12;4)))*1;0)

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    I would also highly recommend NOT using entire column references like L:L in array formulas.
    Limit it to your actual used area like L$1:L$1000

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: R0W() gives error in complex functions

    First of all, it's a terrible idea to use entire column references within an array formula.

    Secondly, the explanation is a touch complex, though, in essence, it boils down to the fact that ROW is a function which has the property that it can return both a single value and an array of values.

    Here, since you are employing the function with an array construction, ROW is coerced into expecting an array of returns, not just a single value. As such, this part (assuming we're talking about a formula in row 1):

    INDIRECT(ADDRESS(ROW(),12,4))

    is resolving to:

    INDIRECT(ADDRESS({1},12,4))

    and not to:

    INDIRECT(ADDRESS(1,12,4))

    the latter of which would evaluate further with no issues.

    It may seem like a small difference - {1} vs 1 - but, when you then continue the evaluation, you see that the former resolves to:

    INDIRECT({"L1"})

    and, since you are attempting to pass an array to INDIRECT - albeit an array containing only a single value - this part errors.

    To resolve this issue, you could use any number of means to coerce the return from ROW into a non-array datatype, e.g.:

    INDIRECT(ADDRESS(SUM(ROW()),12,4))

    which will this time evaluate to:

    INDIRECT(ADDRESS(SUM({1}),12,4))

    and then the SUM resolves this to:

    INDIRECT(ADDRESS(1,12,4))

    which can then be processed without error.

    However, all this is a touch redundant, since the construction you are using is a poor one indeed. Not only is the unqualified ROW() an unrigorous choice in such set-ups (ROWS is far better), but volatile INDIRECT/ADDRESS constructions can almost always be replaced with better, non-volatile ones.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    05-20-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: R0W() gives error in complex functions

    Dear Jonmo1,

    thank you for your explanation.
    However, I used ROW() to return the current row, I cannot find how to return the current row with the ROWS() function.

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    You're welcome.

    Quote Originally Posted by babbelut View Post
    However, I used ROW() to return the current row, I cannot find how to return the current row with the ROWS() function.
    The way I just demonstrated ROWS($A$1:$A112) = 112

    You only need to figure out the row# of the first cell you put the formula in
    As you drag it down/up it will auto incriment.

    Actually
    ADDRESS(ROW();12;4)

    Why not just put L112 ?

  7. #7
    Registered User
    Join Date
    05-20-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: R0W() gives error in complex functions

    As i understand that the function is just bad designed, i will give the whole explanation


    I have two worksheets, let's say WS1 and WS2


    In this screenshot you can see both WS's.

    Image 1.png

    What I want to do is create a hyperlink in column E of WS1 (next to every person)
    This link takes me to WS2, to the row where it finds the month, the name and the firstname.

    Every formula in E needs to be the same, this is what makes it difficult...

    How my function is build now:

    =HYPERLINK("#'WS2'!"&ADDRESS(ROW(INDEX('WS2'!A:C;MATCH(1;('WS2'!A:A=C6)*('WS2'!B:B=D6)*('WS2'!C:C=F6);0);0));1);"My link")


    In F6 I have the following code to find the month...
    =INDIRECT(ADDRESS(SUMPRODUCT(MAX((INDIRECT("B1:"&ADDRESS(ROW();2;4))<>"")*ROW(INDIRECT("B1:"&ADDRESS(ROW();2;4))))); 2; 4))


    If something is not clear, please ask.

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    It looks like the formula's purpose is to find the last non blank cell in column B (up to the row the formula is entered in)
    Is that right?

    Try this in F6 (not required to enter with CSE)

    =LOOKUP(2,1/($B$1:$B6<>""),$B$1:$B6)


    If you insist that you need to use the row function to faciliate finding the end row..

    =LOOKUP(2,1/($B$1:INDEX($B:$B,ROW())<>""),$B$1:INDEX($B:$B,ROW()))
    Last edited by Jonmo1; 10-07-2015 at 09:39 AM.

  9. #9
    Registered User
    Join Date
    05-20-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: R0W() gives error in complex functions

    Jonmo1, that is right.

    But I have simplified my formula to show it here, actually i don't want to show the value of that cell but from another column.
    The real excel looks more like this:

    Image 2.png

    So it will look in column a what the last non blank cell is and then return the value of column B of that row...


    Edit: F6 is also a workaround for the moment, i actually want that part in the hyperlink function too...
    Edit 2: I cannot work with B6 or any other row number, as all functions on all rows will be the same. I have to work with row() or something else to pass the row.

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    Can you attach an actual workbook?
    Pictures don't help alot, we can't copy paste values/formulas from a picture into our own workbooks for troubleshooting.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    Quote Originally Posted by babbelut View Post
    So it will look in column a what the last non blank cell is and then return the value of column B of that row...
    Then change
    =LOOKUP(2,1/($B$1:INDEX($B:$B,ROW())<>""),$B$1:INDEX($B:$B,ROW()))
    to
    =LOOKUP(2,1/($A$1:INDEX($A:$A,ROW())<>""),$B$1:INDEX($B:$B,ROW()))

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    I don't understand this part.
    Quote Originally Posted by babbelut View Post
    I cannot work with B6 or any other row number, as all functions on all rows will be the same.
    Why?

  13. #13
    Registered User
    Join Date
    05-20-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: R0W() gives error in complex functions

    The formula will be entered with software, which is only able to put in the same formula every time...

    I have included an example xls.
    Where "LINK" the formula has to come.
    When I click in the link it has to go to SheetB, where:

    SheetB:ColumnC = SheetA:ColumnL of last row of Column A above the current row
    and
    SheetB:ColumnL = SheetA:ColumnC


    I hope you understand what i am trying to do.
    Attached Files Attached Files

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: R0W() gives error in complex functions

    Quote Originally Posted by babbelut View Post
    I hope you understand what i am trying to do.
    Not really, but I understand what the formula was trying to do.
    It would help if your attached file included the formulas you attemted, and realistic data that they would work off of.

    But anyway..

    This failed because of the row() function returning it's result as an array {6} As described before.
    =INDIRECT(ADDRESS(SUMPRODUCT(MAX((INDIRECT("B1:"&ADDRESS(ROW();2;4))<>"")*ROW(INDIRECT("B1:"&ADDRESS(ROW();2;4))))); 2; 4))

    This formula will produce the same result that formula was trying to accomplish
    =LOOKUP(2,1/($A$1:INDEX($A:$A,ROW())<>""),$B$1:INDEX($B:$B,ROW()))

    Except I changed it to look in column A for the last non blank, instead of B which you had in your original formula.
    Because you said so..


    Also, XOR LX provided a simple solution to make your original formula work.
    Wrap the Row() function in the SUM function.
    SUM CAN handle the array result of the row function, and return it as a non array number.
    In your original, INDIRECT would recieving a reference like INDIRECT({"B1"}) Insetad of INDIRECT("B1")

    So replace ROW() in your formula with SUM(ROW())

+ 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 with complex IF functions
    By colonelbobaloo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-21-2013, 01:42 PM
  2. Accessing complex functions from vba
    By ragulduy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-21-2013, 08:36 AM
  3. Excel 2007 : Relatively complex IF functions
    By chaosreign in forum Excel General
    Replies: 1
    Last Post: 02-04-2012, 09:47 AM
  4. Excel 2007 : Nesting two complex functions?
    By dimi1963 in forum Excel General
    Replies: 6
    Last Post: 10-03-2011, 03:08 PM
  5. Complex If Functions
    By kttrail in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-09-2008, 04:07 PM
  6. help please - complex countif, etc. functions
    By Jennie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] help please - complex countif, etc. functions
    By Jennie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  8. [SOLVED] help please - complex countif, etc. functions
    By Jennie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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