Home

Problem using IF(ISERROR(VLookup(... to see if text matches

%3CLINGO-SUB%20id%3D%22lingo-sub-1129169%22%20slang%3D%22en-US%22%3EProblem%20using%20IF(ISERROR(VLookup(...%20to%20see%20if%20text%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1129169%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20file%20with%20a%20column%20(column%20Z)%20of%20room%20numbers%2C%20and%20I%20am%20trying%20to%20use%20a%20Vlookup%20in%20column%20AA%20to%20see%20if%20the%20room%20number%20is%20listed%20in%20column%20A%20of%20a%20tab%20in%20the%20same%20file%20named%20%22RoomList%22.%20If%20the%20room%20number%20is%20in%20column%20A%2C%20then%20I%20want%20it%20to%20display%20Keep%2C%20and%20if%20not%2C%20display%20Delete.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(ISERROR(VLOOKUP(Z2%2CRoomList!A%3AA%2C1%2C%20TRUE))%2C%22Keep%22%2C%22Delete%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20only%20displaying%20Delete%20for%20everything%2C%20although%20I%20know%20many%20of%20the%20rooms%20numbers%20match.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20much%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1129169%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1129750%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20using%20IF(ISERROR(VLookup(...%20to%20see%20if%20text%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1129750%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F532011%22%20target%3D%22_blank%22%3E%40lbbrown%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlmost%20right.%20Try%20it%20this%20way%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DIF(ISERROR(VLOOKUP(Z2%2CRoomList!A%3AA%2C1%2CFALSE))%2C%22Delete%22%2C%22Keep%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20TRUE%20in%20Vlookup%20almost%20always%20returns%20a%20match.%20E.g.%20if%20you%20have%20two%20room%20numbers%20in%20the%20list%2C%20say%20100%20and%20110%20and%20you%20lookup%20105%2C%20TRUE%20returns%20100.%20Lookup%20120%20and%20you'll%20get%20110.%20It%20picks%20the%20nearest%20number%20not%20greater%20than%20your%20lookup%20value.%20If%20you%20would%20lookup%2090%2C%20however%2C%20you'll%20get%20%23NA!%20So%2C%20if%20you%20are%20not%20searching%20for%20room%20numbers%20that%20are%20lower%20than%20the%20ones%20in%20your%20list%2C%20your%20formula%20never%20returns%20an%20ERROR%20and%20thus%20always%20picks%20the%20second%20option%20%22DELETE%22%20from%20your%20IF-statement.%3C%2FP%3E%3CP%3EUsing%20FALSE%2C%20on%20the%20other%20hand%2C%20always%20forces%20Vlookup%20to%20search%20for%20an%20exact%20match.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1144886%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20using%20IF(ISERROR(VLookup(...%20to%20see%20if%20text%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1144886%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20much.%20That%20worked%20like%20a%20charm.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
lbbrown
New Contributor

I have a file with a column (column Z) of room numbers, and I am trying to use a Vlookup in column AA to see if the room number is listed in column A of a tab in the same file named "RoomList". If the room number is in column A, then I want it to display Keep, and if not, display Delete.

 

=IF(ISERROR(VLOOKUP(Z2,RoomList!A:A,1, TRUE)),"Keep","Delete")

 

It is only displaying Delete for everything, although I know many of the rooms numbers match.

 

Any help would be much appreciated.

 

Thanks

 

2 Replies
Highlighted

@lbbrown 

Almost right. Try it this way:

 

=IF(ISERROR(VLOOKUP(Z2,RoomList!A:A,1,FALSE)),"Delete","Keep")

 

Using TRUE in Vlookup almost always returns a match. E.g. if you have two room numbers in the list, say 100 and 110 and you lookup 105, TRUE returns 100. Lookup 120 and you'll get 110. It picks the nearest number not greater than your lookup value. If you would lookup 90, however, you'll get #NA! So, if you are not searching for room numbers that are lower than the ones in your list, your formula never returns an ERROR and thus always picks the second option "DELETE" from your IF-statement.

Using FALSE, on the other hand, always forces Vlookup to search for an exact match.

 

Highlighted

@Riny_van_Eekelen 

 

Thanks so much. That worked like a charm.