Using an If Statement within a VLookup across sheets

%3CLINGO-SUB%20id%3D%22lingo-sub-2777479%22%20slang%3D%22en-US%22%3EUsing%20an%20If%20Statement%20within%20a%20VLookup%20across%20sheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2777479%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20work%20sheet%20which%20has%20multiple%20tabs%20showing%20vehicle%20data%20I%20also%20have%20a%20lookup%20tab%20so%20that%20when%20I%20enter%20a%20registration%20it%20will%20show%20me%20the%20relevant%20details%20and%20which%20branch%20the%20vehicle%20belongs%20to%20I%20have%20used%20the%20below%20formula%20using%20an%20indirect%20%26amp%3B%20index%20for%20referencing%20the%20different%20sheets%20with%20an%20iferror%20to%20show%20me%20error's%20and%20an%20if%20to%20show%20blanks%20when%20value%20is%20empty%20or%200.%26nbsp%3B%3D(IFERROR(IF(LEN(VLOOKUP(C11%2CINDIRECT(%22'%22%26amp%3BINDEX(Sheet_Names%2CMATCH(1%2C--(COUNTIF(INDIRECT(%22'%22%26amp%3BSheet_Names%26amp%3B%22'!A3%3AA700%22)%2CC11)%26gt%3B0)%2C0))%26amp%3B%22'!%24A%243%3A%24AA%24700%22)%2C3%2C0))%3D0%2C%22Not%20Found%22%2CVLOOKUP(C11%2CINDIRECT(%22'%22%26amp%3BINDEX(Sheet_Names%2CMATCH(1%2C--(COUNTIF(INDIRECT(%22'%22%26amp%3BSheet_Names%26amp%3B%22'!%24A%243%3A%24A%24700%22)%2CC11)%26gt%3B0)%2C0))%26amp%3B%22'!%24A%243%3A%24AA%24700%22)%2C3%2C0))%2C%22%22)).%20The%20problem%20I%20have%20though%20is%20when%20a%20vehicle%20is%20used%20again%20at%20another%20branch%20the%20Lookup%20will%20go%20to%20the%20first%20value%20now%20there%20is%20a%20duplicate%2C%20I%20have%20added%20another%20column%20to%20show%20vehicles%20active%20yes%20and%20no%20so%20I%20want%20my%20lookup%20to%20now%20only%20return%20the%20vehicle%20if%20active%20yes%20which%20will%20get%20rid%20of%20the%20duplicate%2C%20However%20I%20am%20struggling%20to%20right%20this%20in%20my%20formula%20and%20I'm%20guessing%20there%20needs%20to%20be%20another%20if%20statement%20to%20tell%20the%20lookup%20to%20find%20the%20registration%20if%20active...Someone's%20help%20would%20be%20greatly%20appreciated.%3C%2FP%3E%3CP%3ECopy%20of%20spreadsheet%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2777479%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2777815%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20an%20If%20Statement%20within%20a%20VLookup%20across%20sheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2777815%22%20slang%3D%22en-US%22%3EI%20would%20combine%20all%20data%20on%20a%20single%20sheet%20with%20an%20added%20%22Fleet%22%20column%20and%20ditch%20the%20individual%20Fleet%20sheets%2C%20they%20lead%20to%20a%20lot%20of%20unnecessary%20complexity%20in%20your%20formulas.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2777821%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20an%20If%20Statement%20within%20a%20VLookup%20across%20sheets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2777821%22%20slang%3D%22en-US%22%3EHi%3CBR%20%2F%3EThanks%20for%20responding%20to%20me%20would%20I%20not%20have%20the%20same%20problem%20on%20one%20sheet%20though%3F%20If%20I%20combined%20all%20on%20one%20sheet%20how%20would%20I%20get%20my%20lookup%20just%20to%20show%20the%20active%20vehicles%20when%20there%20are%20duplicates%3F%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

I have a work sheet which has multiple tabs showing vehicle data I also have a lookup tab so that when I enter a registration it will show me the relevant details and which branch the vehicle belongs to I have used the below formula using an indirect & index for referencing the different sheets with an iferror to show me error's and an if to show blanks when value is empty or 0. =(IFERROR(IF(LEN(VLOOKUP(C11,INDIRECT("'"&INDEX(Sheet_Names,MATCH(1,--(COUNTIF(INDIRECT("'"&Sheet_Names&"'!A3:A700"),C11)>0),0))&"'!$A$3:$AA$700"),3,0))=0,"Not Found",VLOOKUP(C11,INDIRECT("'"&INDEX(Sheet_Names,MATCH(1,--(COUNTIF(INDIRECT("'"&Sheet_Names&"'!$A$3:$A$700"),C11)>0),0))&"'!$A$3:$AA$700"),3,0)),"")). The problem I have though is when a vehicle is used again at another branch the Lookup will go to the first value now there is a duplicate, I have added another column to show vehicles active yes and no so I want my lookup to now only return the vehicle if active yes which will get rid of the duplicate, However I am struggling to right this in my formula and I'm guessing there needs to be another if statement to tell the lookup to find the registration if active...Someone's help would be greatly appreciated.

Copy of spreadsheet attached.

 

 

6 Replies
I would combine all data on a single sheet with an added "Fleet" column and ditch the individual Fleet sheets, they lead to a lot of unnecessary complexity in your formulas.
Hi
Thanks for responding to me would I not have the same problem on one sheet though? If I combined all on one sheet how would I get my lookup just to show the active vehicles when there are duplicates?

@Loki_bear_21 

You can highlight it by conditional formatting

 

JulianoPetrukio_0-1632392659805.png

 

or using a formula to count the quantity of that vehicle is duplicates

=COUNTIF(VehicleList,Vehicle)>1

Depends on how you want to determine which vehicle to display?

Perhaps something like the attached, where I have added slicers to filter the table?

I want the vehicle to be displayed once it is active which is determined by a yes or no for example vehicle moved from one branch to another the second branch being where the vehicle is now active
I know that your current approach is use excel to manage it.
But I would suggest you using MS Access to manage it properly. Specially because MS Access can generate more easily a lot of different reports.