Using Vlookup for IF statements
First you need to create a table. In the example below, I'm using colums A
and B. This table needs to be in ascending order.
# COUNTRYSTOCK
404-BU PACIFIC
404-CA WEST
404-DA ATLANTIC
404-ED WEST
404-LO CENTRAL
404-M1 CENTRAL
404-M2 CENTRAL
404-MJ EAST
404-MO EAST
404-OT EAST
404-QU EAST
404-SA WEST
404-SH EAST
404-VI PACIFIC
404-WI WEST
Then you can use this formula:
=IF(ISERROR(VLOOKUP(D1,A1:B16,2,0)),FALSE,VLOOKUP( D1,A1:B16,2,0))
If the lookup returns an error because it's not found, then the ISERROR will
return False.
HTH,
Paul
"Addy" wrote in message
ups.com...
Hello there,
I have a rather long IF statement, and as we all know that Excel only
accepts upto 7 IFs statments within the nest.
IF(ISNUMBER(SEARCH("#",D2)),"COUNTRYSTOCK",IF(ISNU MBER(SEARCH("404-
BU",D2)),"PACIFIC",IF(ISNUMBER(SEARCH("404-
VI",D2)),"PACIFIC",IF(ISNUMBER(SEARCH("404-
CA",D2)),"WEST",IF(ISNUMBER(SEARCH("404-
ED",D2)),"WEST",IF(ISNUMBER(SEARCH("404-
SA",D2)),"WEST",IF(ISNUMBER(SEARCH("404-
WI",D2)),"WEST",IF(ISNUMBER(SEARCH("404-
M1",D2)),"CENTRAL",IF(ISNUMBER(SEARCH("404-
M2",D2)),"CENTRAL",IF(ISNUMBER(SEARCH("404-
LO",D2)),"CENTRAL",IF(ISNUMBER(SEARCH("404-
OT",D2)),"EAST",IF(ISNUMBER(SEARCH("404-
MO",D2)),"EAST",IF(ISNUMBER(SEARCH("404-
SH",D2)),"EAST",IF(ISNUMBER(SEARCH("404-
QU",D2)),"EAST",IF(ISNUMBER(SEARCH("404-
MJ",D2)),"EAST",IF(ISNUMBER(SEARCH("404-
DA",D2)),"ATLANTIC","FALSE"))))))))))))))))
Above is my IF statement. Basically it is looking at a part of a
string in column and using a condition.
I am not sure about the Vlookup formula. I have a hunch I could use it
in place of this. Can someone help me get started on it?
|