Hi!
Very Big Grin
Quit "stonewalling" and tell us how many sheets you actually have! <vbg>
That was a tongue-in-cheek way of "chastising" you for "changing the
parameters" of your post. This happens quite often. If posters would ask
their questions and tell us the "REAL DEAL" then multiple follow-ups would
not be needed.
I throw in the <vbg> so that it's taken with a grain of salt!
OK, with 4 sheets to lookup that sort of falls into a gray area as to which
formula will be more efficient. You could use the formula Dave showed you:
=IF(NOT(ISERROR(VLOOKUP(A1,Sheet2!A:B,2,0))),VLOOKUP(A1,Sheet2!A:B,2,0),IF(NOT(ISERROR(VLOOKUP(A1,Sheet3!A:B,2,0))),VLOOKUP(A1,Sheet3!A:B,2,0),IF(NOT(ISERROR(VLOOKUP(A1,Sheet4!A:B,2,0))),VLOOKUP(A1,Sheet4!A:B,2,0),IF(NOT(ISERROR(VLOOKUP(A1,Sheet5!A:B,2,0))),VLOOKUP(A1,Sheet5!A:B,2,0),""))))
But that's kind of a long formula. And if you have real long sheet names,
it'll be even longer! I HATE real long sheet names, by the way! <vbg> "Long"
formulas tend to "scare" people!
Another method:
Enter the sheet names in a range, say, J1:J4 -
J1 = Sheet2
J2 = Sheet3
J3 = Sheet4
J4 = Sheet5
Now, give that range a defined name:
Insert>Name>Define
Name: WsList
Refers to: =Sheet1$J$1:$J$4
Lookup formula entered as an array using the key combo of CTRL,SHIFT,ENTER:
=VLOOKUP(A1,INDIRECT("'"&INDEX(WsList,MATCH(TRUE,COUNTIF(INDIRECT("'"&WsList&"'!A:A"),A1)>0,0))&"'!A:B"),2,0)
Quite a bit shorter, ain't it!
The nested IF formula does a lookup on each sheet until it finds the lookup
value. The above formula does only a single lookup but it uses the Countif
and Index/Match functions to find which sheet to do the lookup on. If you
had more than 4 sheets to lookup then the above formula is the way to go.
The nested IF contains an error trap. The above does not. Here it is with an
error trap:
=IF(SUMPRODUCT(COUNTIF(INDIRECT("'"&WSlist&"'!A:A"),A1)),VLOOKUP(A1,INDIRECT("'"&INDEX(WSlist,MATCH(TRUE,COUNTIF(INDIRECT("'"&WSlist&"'!A:A"),A1)>0,0))&"'!A:B"),2,0),"")
A little bit longer but still not a monster!
Biff