+ Reply to Thread
Results 1 to 26 of 26

Array Formula in place of vlookup?

  1. #1
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Array Formula in place of vlookup?

    Hi,

    I have the following formula to look up a cell value (A3) using VLOOKUP and if it matches the lookup value, put "0", otherwise leave it blank.

    Please Login or Register  to view this content.
    The issue of course is that if the first value in the lookup doesn't match A3 then it simply stops rather than finding the match. I think this is done by Index Match or an Array, but I can't remember what the formula should be and my google-fu skills are failing.

    Can anyone help?

    Edited: Attached sheet
    Edited #2: Amended formula example above to match attachment.
    Edited #3: Anebded example to show expected results.
    Attached Files Attached Files
    Last edited by Barking_Mad; 03-15-2022 at 08:26 AM.

  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,036

    Re: Array Formula in place of vlookup?

    Hi there.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 non-editable pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet complete with an explanation and some expected results.
    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 Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    Why not this?

    =IF(I$1=IFNA(VLOOKUP(A3,'Report'!$A$2:$M$10001,13,FALSE),0),0,"")

    Don't put 0 into inverted commas unless you want text returned instead of a real number.

    Administrative Note:

    Members will tailor the solutions they offer to the version (NOT release number) of Office (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    APologies, sheet uploaded. I was trying to do it via the paperclip, but that wasnt working, only remembered about 'manage attachments' when I saw it further down

    Profile update too
    Last edited by AliGW; 03-15-2022 at 07:15 AM. Reason: PLEASE don't quote unnecessarily!

  5. #5
    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,036

    Re: Array Formula in place of vlookup?

    I'm still somewhat baffled... is this what you want?

    =IF(B$1=VLOOKUP($A2,$G$2:$H$6,2),0,"")

    copied across and down. if not, please amend the sheet to show your EXPECTED results...
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Array Formula in place of vlookup?

    Your test sheet is not quite the same as your example formula. You seem to have used absolute references for things which is not quite correct. It also looks like you've made a mistake in a couple of cells (e.g. C2 and D2 both refer to $C$1).

    Taking your formula in B2 as a starting point:

    =IF($B$1=VLOOKUP(A2,$G$2:$H$6,2),0,"")

    The $B$1 reference (in red) should be B$1 which will keep it in the first row but move along the columns when copied. You had this correct in the formula in your first post.

    The A2 reference (blue) should be $A2 which will keep it in column A but move down the rows when copied.

    At the end of the VLOOKUP statement you have omitted ,FALSE which you correctly had in your first post. (I use 0 instead of FALSE as it's quicker to type)

    So you should end up with:

    =IF(B$1=VLOOKUP($A2,$G$2:$H$6,2,0),0,"")

    This works but will give you #N/A for ID 4 which is not in your reference table. To avoid this you could wrap it in IFERROR, e.g.

    =IFERROR(IF(B$1=VLOOKUP($A2,$G$2:$H$6,2,0),0,""),"")

    NB You can use INDEX and MATCH instead of VLOOKUP if you prefer, it's a similar solution:

    =IFERROR(IF(B$1=INDEX($H$2:$H$6,MATCH($A2,$G$2:$G$6,0)),0,""),"")

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    @BarkingMad

    Any response to my suggestion? Maybe you missed it.

  8. #8
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by Glenn Kennedy View Post
    I'm still somewhat baffled... .
    Hi,

    I've updated the sheet. Hopefully Ive replaced my crap example

    Column C (C2:C5) should populate with 0 for all the IDs as per column F, but it doesn't, presumably as it stops at the first vlookup (?)
    Last edited by AliGW; 03-15-2022 at 07:15 AM. Reason: PLEASE don't quote unnecessarily!

  9. #9
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by AliGW View Post
    Why not this?...
    Hi,

    Sorry, trying to do 10 things at once...This didnt seem to work, but im possibly misunderstanding something
    Last edited by AliGW; 03-15-2022 at 07:14 AM. Reason: PLEASE don't quote unnecessarily!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    Thanks for updating your profile.

  11. #11
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Array Formula in place of vlookup?

    Ah I see what you mean now, how about this (in B2, copied to others):

    =IF(SUM(($E$2:$E$11=$A2)*($F$2:$F$11=B$1))>0,0,"")

  12. #12
    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,036

    Re: Array Formula in place of vlookup?

    That is NOT what I asked for. I have no idea what you are trying to achieve... I need to see EXPECTED answers... and not a formula that does not work

  13. #13
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by Glenn Kennedy View Post
    That is NOT what I asked for. I have no idea what you are trying to achieve... I need to see EXPECTED answers... and not a formula that does not work
    Hi,

    Ive put 0 in red in the other column to show you what's EXPECTED. Thanks.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    This seems a very odd thing to be doing - it would help to explain this in context.

  15. #15
    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,036

    Re: Array Formula in place of vlookup?

    I have absolutely no idea what you are trying to achieve... one more random guess....


    =IF($B$1=VLOOKUP($A2,$E$2:$F$11,2),0,"")

    copied across and down.
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Array Formula in place of vlookup?

    I still think my solution works...

    As far as I can tell, the issue the OP had was that they are running a test for if something equals a VLOOKUP result, but want to check against all possible results rather than just the first.

  17. #17
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by AliGW View Post
    This seems a very odd thing to be doing - it would help to explain this in context.
    Hi Ali,

    It's basically an absence tracking sheet.

    Columns F:G are on one sheet which is added to each week (wk1, then wk2 etc.) with students who are absent.
    Columns A:D are on another sheet with all the students on. They reflect any absences by putting a 0 (which conditionally formats to red) when a student appears on the other sheet.

    It's not an ideal way of doing things but unforutnately those 'in charge' devised an expensive absence system with no front end for users) #highereducation

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    There's nothing in columns D or G ...

    AliGW on MS365 Insider (Windows) 64 bit

    A
    B
    C
    D
    E
    F
    1
    ID
    Wk1
    Wk2
    ID
    Week
    2
    1
    0
    0
    1
    Wk1
    3
    2
    0
    0
    2
    Wk1
    4
    3
    0
    0
    3
    Wk1
    5
    4
    0
    0
    4
    Wk1
    6
    5
    0
    0
    5
    Wk1
    7
    1
    Wk2
    8
    2
    Wk2
    9
    3
    Wk2
    10
    4
    Wk2
    11
    5
    Wk2
    Sheet: Sheet1

  19. #19
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by nick.williams View Post
    I still think my solution works...

    As far as I can tell, the issue the OP had was that they are running a test for if something equals a VLOOKUP result, but want to check against all possible results rather than just the first.
    Hi, just trying to test it now.... And yes, if the user ID appears in the list in columns F:G, then it should be reflected in the appropriate Wk column in B:D. I think the issue is that it only checks the first value found for the ID in column F, rather than the ones that provides the match.

  20. #20
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by AliGW View Post
    There's nothing in columns D or G ...

    AliGW on MS365 Insider (Windows) 64 bit

    A
    B
    C
    D
    E
    F
    1
    ID
    Wk1
    Wk2
    ID
    Week
    2
    1
    0
    0
    1
    Wk1
    3
    2
    0
    0
    2
    Wk1
    4
    3
    0
    0
    3
    Wk1
    5
    4
    0
    0
    4
    Wk1
    6
    5
    0
    0
    5
    Wk1
    7
    1
    Wk2
    8
    2
    Wk2
    9
    3
    Wk2
    10
    4
    Wk2
    11
    5
    Wk2
    Sheet: Sheet1
    Sorry, I meant E:F
    Last edited by Barking_Mad; 03-15-2022 at 08:18 AM.

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    Still no idea why you want to return 0. To me, this is what you appear to be describing:

    =COUNTIFS($E$2:$E$11,$A2,$F$2:$F$11,B$1)

  22. #22
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Array Formula in place of vlookup?

    If they only appear once per week for absences, I'd have thought just:

    =1-COUNTIFS($E:$E,$A2,$F:$F,B$1)

    in B2 copied across and down. If they could appear more than once per week, you can use:

    =1-(COUNTIFS($E:$E,$A2,$F:$F,C$1)>0)
    Rory

  23. #23
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Quote Originally Posted by AliGW View Post
    Still no idea why you want to return 0. To me, this is what you appear to be describing:

    =COUNTIFS($E$2:$E$11,$A2,$F$2:$F$11,B$1)
    It was basically checking to see if the value existed (0 was an arbitary number to show non-attendance), but I didnt think of using COUNTIF instead of vlookup. Thanks for your patience, this works just as well.

  24. #24
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Array Formula in place of vlookup?

    Thanks for your help everyone. Ill ensure to be more thorough with my original post next time

  25. #25
    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,036

    Re: Array Formula in place of vlookup?

    Woo Hoo! Someone figured it out!!!

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Array Formula in place of vlookup?

    By accident, it seems ... Thanks for the rep.

+ 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] Non Array Formula to Extract Unique Values in column A2:A61 and Place in B2:B61
    By bjnockle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-10-2021, 01:25 PM
  2. [SOLVED] Using VBA in place of array formula
    By Frankie_The_Flyer in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-06-2019, 05:03 AM
  3. Formula in place of current vlookup
    By jenniestokes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-04-2019, 01:59 PM
  4. [SOLVED] Array SUMIF formula to sum if numbers but it not place text
    By jed38 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-10-2014, 05:54 PM
  5. [SOLVED] Excel 2003 Array as input - how to place output in a second array?
    By theelkhunter in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-10-2013, 02:04 PM
  6. Place formula in cell using vlookup
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2012, 03:03 PM
  7. can vlookup place results in a different box than the formula?
    By Psychlogic in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-24-2006, 07:15 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