+ Reply to Thread
Results 1 to 10 of 10

Array formula returns wrong results when source data is moved from the top row

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Array formula returns wrong results when source data is moved from the top row

    Hi,

    I have been looking online on how to fix my formula. It is an array formula that will only give correct results when the data is at the TOP row, that is row 1, regardless of the column. When I cut and paste the formula below row 1, the results are wrong.

    Here is my formula:
    Please Login or Register  to view this content.
    The source data is in a sheet named DATA. I attached the Excel file with the link below:
    http://www.excelforum.com/attachment...1&d=1468392371

    Can you please help me fix my array formula?
    The goal of the array formula is to list the serial code (first column) if the value in the third column is NOT zero.

    Thank you very much.
    Attached Files Attached Files

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Array formula returns wrong results when source data is moved from the top row

    Not real sure what you're trying to do.

    Since you're using Excel 2010 you can use the IFERROR function and reduce the formula length by half...

    Array entered in B13 and copied down:

    =IFERROR(INDEX(Data!$G:$G,SMALL(IF(Data!$J$1:$J$152<>0,ROW(Data!$J$1:$J$152)),ROWS(B$13:B13))),"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Array formula returns wrong results when source data is moved from the top row

    try the following Array Formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Array formula returns wrong results when source data is moved from the top row

    Quote Originally Posted by Tony Valko View Post
    Not real sure what you're trying to do.

    Since you're using Excel 2010 you can use the IFERROR function and reduce the formula length by half...

    Array entered in B13 and copied down:

    =IFERROR(INDEX(Data!$G:$G,SMALL(IF(Data!$J$1:$J$152<>0,ROW(Data!$J$1:$J$152)),ROWS(B$13:B13))),"")
    Hi Tony,

    Thank you for your suggested formula. Indeed it is shorter and it worked the same as my original formula, so the problem is the same.
    The formula (mine and your shortened version) actually works, but the problem is, when I MOVE the source data through CUT and PASTE to another location in the sheet. The formula gives wrong results.

    For instance,in the sample file I attached, the SOURCE data is in DATA sheet located in range G1:J152. When I cut and paste that range (G1:J152) to say G10:J161, your formula still WORKED, but mine DIDN'T!

    However, there is one more problem, when I cut the source data and paste NOT in the G column, say in A10:D161, your formula and mine both give wrong results!

    I believe the problem is in the last part of the formula that says ROWS(B$13:B13)? But I am not really sure how to make the formula give the same correct results even if you CUT and PASTE the source range to another location.

    Thank you very much.

  5. #5
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Array formula returns wrong results when source data is moved from the top row

    Quote Originally Posted by jewelsharma View Post
    try the following Array Formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you Jewel for your reply. I tried the formula you gave me, with the source data in range D1:J152, the formula showed results of 0.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Array formula returns wrong results when source data is moved from the top row

    oops, wrong range. try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Array formula returns wrong results when source data is moved from the top row

    Quote Originally Posted by kolokoy View Post
    I believe the problem is in the last part of the formula that says ROWS(B$13:B13)?
    No, ROWS(B$13:B13) is just an incrementer. The reference should be to the first cell the formula is entered into. If the first cell you enter the formula into is K27 then it should be ROWS(K$27:K27).

    Try this...

    =IFERROR(INDEX(Data!$G$1:$G$152,SMALL(IF(Data!$J$1:$J$152<>0,ROW(Data!$J$1:$J$152)-MIN(ROW($J$1:$J$152))+1),ROWS(B$13:B13))),"")

    Change the highlighted portion to correspond to the first cell the formula is entered into.

    Still array entered.

  8. #8
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Array formula returns wrong results when source data is moved from the top row

    Quote Originally Posted by jewelsharma View Post
    oops, wrong range. try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you very much Jewel! This formula worked the way I really wanted!

  9. #9
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Array formula returns wrong results when source data is moved from the top row

    Quote Originally Posted by Tony Valko View Post
    No, ROWS(B$13:B13) is just an incrementer. The reference should be to the first cell the formula is entered into. If the first cell you enter the formula into is K27 then it should be ROWS(K$27:K27).

    Try this...

    =IFERROR(INDEX(Data!$G$1:$G$152,SMALL(IF(Data!$J$1:$J$152<>0,ROW(Data!$J$1:$J$152)-MIN(ROW($J$1:$J$152))+1),ROWS(B$13:B13))),"")

    Change the highlighted portion to correspond to the first cell the formula is entered into.

    Still array entered.
    Thank you Tony for the formula. But still it did not work. I used Jewel's formula above and it worked exactly the way I need it to work. Thank you very much for your input!

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Array formula returns wrong results when source data is moved from the top row

    Good deal. Thanks for the feedback!

+ 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. [SOLVED] match function lookup array returns wrong value
    By elenama in forum Excel General
    Replies: 5
    Last Post: 08-17-2015, 06:13 AM
  2. Replies: 14
    Last Post: 01-15-2014, 09:42 AM
  3. [SOLVED] VBA replacing a formula with a macro returns #Value (Wrong data type)
    By silent3486 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-14-2013, 04:17 PM
  4. Formula returns wrong data type
    By mbrown89 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 01-30-2010, 12:36 PM
  5. How change link source in long formula when source moved
    By Irina in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2006, 02:30 AM
  6. FORMULA at Source range (in Data->validation->List) gives wrong re
    By Eddy Stan in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-17-2006, 03:25 AM
  7. [SOLVED] Array formula returning wrong results
    By TUNGANA KURMA RAJU in forum Excel General
    Replies: 1
    Last Post: 11-19-2005, 06:35 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