+ Reply to Thread
Results 1 to 6 of 6

Array formula returns erroneous results

  1. #1
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Array formula returns erroneous results

    I have a data set SalesList with 4 columns: FName, MName, LName, Zone

    Each zone has a worksheet with 4 columns: Seq#, LastName, FirstName, Zone

    For each zone I create a separate worksheet that pulls down all names (FName&LName) from SalesList that are in the same zone, to eliminate transcription errors.

    Zone names can be alphanumeric: e.g., Neptune, Panda, Puma, Kingsman, 1st, 2nd, …25th

    Every zone has between 8 and 30 names, but some can be max 50.

    My array formula for
    last name: {=IFERROR(IF(COUNTIF(SalesList!$D$2:$D$92,$D$1) < ROWS($B$2:B2), "", INDEX(SalesList!$C$2:$C$92, SMALL( IF(SalesList!$D$2:$D$92 =$D$1, ROW( SalesList!$D$2:$D$92)), ROW(SalesList!D2)))),"")}
    first name: =IFERROR(IF(COUNTIF(SalesList!$D$2:$D$92,$D$1) < ROWS($B$2:C2), "", INDEX(SalesList!$A$2:$A$92, SMALL( IF(SalesList!$D$2:$D$92 =$D$1, ROW( SalesList!$D$2:$D$92)), ROW(SalesList!D1)))),"")

    Note: $D$1 in above formula refers to the title row which takes its name from the filename of the worksheet: The formula in $D$1: =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
    I did try to replace the formula by typing in the name of the worksheet, no difference.

    These two formulas do pickup and populate exact number of names in the data set with corresponding zones, but it's a mish/mash of results. worksheets.

    Every zone is missing the first name in the zone.

    Every zone lists the last Name from the next zone, i.e., the Neptune zone has a Name from Panda and is listed as Neptune. The Panda zone has a Name from Puma and is listed as Panda.

    Starting with the Panda worksheet, every Name listed first in the zone worksheet list, even though it is the second Name in the SalesList, has the wrong last name.

    For third Name, It picks up the correct first name, but picks up the last name of the second Name following listed in the zone worksheet, i.e., picks up the third Name’s last name from the SalesList worksheet.

    Is there a better alternative to array formulas that can be used in this case?

    Any help or suggestion would be very much appreciated.

    Regards,
    JC

  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
    43,895

    Re: Array formula returns erroneous results

    The party of the first part shall hereafter be known as the party of the first part.... (Groucho Marx).

    I can't follow that.

    One guess:
    {=IFERROR(IF(COUNTIF(SalesList!$D$2:$D$92,$D$1) < ROWS($B$2:B2), "", INDEX(SalesList!$C:$C, SMALL( IF(SalesList!$D$2:$D$92 =$D$1, ROW( SalesList!$D$2:$D$92)), ROW(SalesList!D2)))),"")}

    and similarly for the other one. If that's not it...

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    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
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Array formula returns erroneous results

    Thank you Glenn for your help. I have prepared such a data in anticipation. so here it is.
    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
    43,895

    Re: Array formula returns erroneous results

    Col B:

    =IFERROR(INDEX(SalesList!$C:$C, SMALL( IF(SalesList!$D$2:$D$92 =$D$1, ROW( SalesList!$D$2:$D$92)), ROWS(B$2:B2))),"")

    Col C

    =IFERROR(INDEX(SalesList!$A:$A, SMALL( IF(SalesList!$D$2:$D$92 =$D$1, ROW( SalesList!$D$2:$D$92)), ROWS(C$2:C2))),"")

    both array-entered and Col D:

    =IF(B2<>"",D1,"")

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Thumbs up Re: Array formula returns erroneous results

    Oh, I see, the "countif" was messing the formula.

    Thank you very much I really appreciate your help.

  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
    43,895

    Re: Array formula returns erroneous results

    No. It just wasn't necessary. It was the range

    YOU: INDEX(SalesList!$C$2:$C$92

    ME: INDEX(SalesList!$C:$C

    You were one row out as ROW returns sheet row numbers and by starting from C2, you were one out...

    Anyhow.


    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Replies: 9
    Last Post: 07-14-2016, 06:44 AM
  2. VBA code for custom function that returns detail results of array function
    By onechipshot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2015, 06:30 PM
  3. [SOLVED] When a cell is left blank the formula returns results
    By jendore in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-13-2014, 11:27 AM
  4. Dragged formula returns incorrect results
    By ybortony in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-19-2014, 02:27 PM
  5. Need Index formula that returns multiple results
    By jaimeteele in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-06-2013, 04:28 PM
  6. [SOLVED] Same Sum Formula Returns Different Results
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-06-2012, 07:07 PM
  7. [SOLVED] VLOOKUP Returns Erroneous Value When Control Data is Variable
    By The Hawk in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-22-2006, 11:45 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