+ Reply to Thread
Results 1 to 16 of 16

vlookup combined with If & AND not working

  1. #1
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    vlookup combined with If & AND not working

    Hi,

    I need to monitor a file out of the data obtained from another source.

    The below works:
    =IF(L4=VLOOKUP(L4,'CSVAssetRegister4_5_2017 3_50_06 PM.xlsx'!$N$2:$N$23084,1,FALSE),TRUE,FALSE)


    But the below does not work & not giving correct result - content of N3 or "Not in SAR" even when it has to, instead it displays #N/A:

    =If(AND(VLOOKUP(L3,'[CSVAssetRegister4_5_2017 3_50_06 PM.xlsx]CSVAssetRegister4_5_2017 3_50_0'!$N$2:$V$23084,1,FALSE)=L3,(VLOOKUP(N3,'[CSVAssetRegister4_5_2017 3_50_06 PM.xlsx]CSVAssetRegister4_5_2017 3_50_0'!$N$2:$V$23084,9,FALSE)=N3),N3,"Not in SAR")

    Please suggest correction if any in the above formula.


    Shreeniwas

  2. #2
    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
    79,369

    Re: vlookup combined with If & AND not working

    Welcome to the forum!

    Check that the contents of N3 and the matching value in the lookup array are a true match - there may be a slight difference (trailing or leading spaces, etc.).

    Also check that the column reference in red is the correct column in the lookup array:

    =If(AND(VLOOKUP(L3,'[CSVAssetRegister4_5_2017 3_50_06 PM.xlsx]CSVAssetRegister4_5_2017 3_50_0'!$N$2:$V$23084,1,FALSE)=L3,(VLOOKUP(N3,'[CSVAssetRegister4_5_2017 3_50_06 PM.xlsx]CSVAssetRegister4_5_2017 3_50_0'!$N$2:$V$23084,9,FALSE)=N3),N3,"Not in SAR")
    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.

  3. #3
    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,893

    Re: vlookup combined with If & AND not working

    In the first lookup you seem to be Taking the value in L3, looking it up in the 1st column of that range, and if it is there, then return the value of L3???? Does that make any sense at all?

    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

  4. #4
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Hi Ali - Thanks for your update. 9 is correct & also data is correct, I rechecked.

    Hi Glenn - Thanks for your response. I will re-try the formulae with smaller version of the files & update the attachment by EOD. Thanks again.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: vlookup combined with If & AND not working

    What do you get when you break that apart and put each vlookup in it's own cell?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Hi Glenn,


    Sorry for the delay.

    I have attached the two short files - test 1 & test2.

    Here, in Test1 file in column G I want TRUE or FALSE if corresponding value matches with the respective one. And the above formula is not working.

    Kindly suggest.


    Shreeniwas Sovani


    Hi FDibbins,

    Hope you will find above input useful. Your inputs will help me for future reference. Actually, I am not conversant with VBA. Do suggest on correct formula in column G in test1 file.


    Shreeniwas Sovani
    Attached Files Attached Files

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

    Re: vlookup combined with If & AND not working

    Try this array formula:
    =IF(ISNUMBER(MATCH(1,('[Test2.xlsx]Sheet2'!$B$3:B$27=B3)*('[Test2.xlsx]Sheet2'!$D$3:$D$27=D3),0)),TRUE,FALSE)

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    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

  8. #8
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Hi Glenn,


    Thanks for the formula you shared.

    I was trying to make use of the solution you shared & but was unable to use.

    It works with Cntrl+Shift+Enter. But, due to this limitation, I am unable to use the formula practically. If you can suggest corrections to the formula I use it will be helpful. i.e. combination of if, AND & vlookup & results TRUE /False or respective values. Or alternate formula which does not require features like Cntrl+Shift+Enter & can be used with TRUE/ False or values, preferably values. As in my case values will be more meaningful.

    Thanks again.


    Shreeniwas Sovani

  9. #9
    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
    79,369

    Re: vlookup combined with If & AND not working

    Could you please explain why you are unable to use array formulae that require entry with CTRL+SHIFT+ENTER? They do not require your workbooks to be macro-enabled or anything like that.

  10. #10
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Hi Ali,

    Thanks for your response.

    The formula so as to work requires that we need to go to the cell & press F2 & press CTRL+SHIFT+ENTER. And this needs to be done for each cell. And data size is more. And it is not feasible to go to each cell & carry out this operation. I tried recopying onto multiple cells & press CTRL+SHIFT+ENTER but it does not work. It works only when I go to each cell.


    Shreeniwas Sovani

  11. #11
    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
    79,369

    Re: vlookup combined with If & AND not working

    You can drag copy array formulae down a column in the same way that you would any other formula.

  12. #12
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Oh with drag copy it seems formula works. I used to use Ctrl+C/ Ctrl+V for copying with which it was not working. Let me check for all the cases.

    Thanks for the quick response.


    Shreeniwas

  13. #13
    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
    79,369

    Re: vlookup combined with If & AND not working

    You're welcome!

  14. #14
    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,893

    Re: vlookup combined with If & AND not working

    The way you described it, it will not work, Shreeniwas. You have to set the array in ONE cell and then drag it as required. If you do it the way you tried, you will get the same answer in every cell!!!

  15. #15
    Registered User
    Join Date
    04-14-2017
    Location
    Pune
    MS-Off Ver
    2013
    Posts
    7

    Re: vlookup combined with If & AND not working

    Yes Glen. Thanks so much. Finally, I could resolve some of the requirements with above formula.

    Shreeniwas

  16. #16
    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
    79,369

    Re: vlookup combined with If & AND not working

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

+ 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: 2
    Last Post: 09-16-2014, 12:01 PM
  2. [SOLVED] SUMPRODUCT and INDIRECT functions not working with a ROW reference when combined
    By Duoae in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2014, 03:28 AM
  3. Combined Two Codes but Not working
    By bhaddya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2013, 01:59 PM
  4. [SOLVED] IF combined with VLOOKUP
    By dave9860E in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-03-2013, 12:58 AM
  5. Vlookup first name out of combined name?
    By bruizer31 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2013, 02:03 PM
  6. combined if and vlookup
    By johnf711 in forum Excel General
    Replies: 1
    Last Post: 06-29-2012, 10:58 PM
  7. Sub procedures stop working when combined.
    By isrisian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2011, 01:39 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