![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: Sydney - Australia
Posts: 7
|
I have a column of no's inside a spreadsheet which designate a class of products within a group. I have tried to use the IF but it only works for the 1st argument and not the 2nd 3rd etc. What am I doing wrong and is there a more efficient way of doing this simple chore.
A B C 1 2012 2 2012 3 2013 4 3019 5 6014 6 7015 I am trying =IF(B1={2012,2013,3019,6014,7015},"Bats","Balls","Gloves","Wheels","Pumps") Thanks in advance, Bill Tahu |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
I think you're looking for:
=VLOOKUP(B1,{2012,"Bats";2013,"Balls";3019,"Gloves";6014,"Wheels";7015,"Pumps"},2,0) |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 809
|
IF will return one value, or another, it is not expected to return multiple values.
Were this in VBA, I would suggest Select Case. What you are trying to do is: IF the value is ______, then _______ OR IF the value is ______, then _______ OR IF the value is ______, then _______ You get the idea. You will need to construct a number of IF statements, and string them together. In VBA, the best construct would be Select Case. I stay away from complex cell formula, and this would be a complex cell formula, if it can be done at all. I am not the person to help you on this, since my gut feeling is "it can't be done". |
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Location: Sydney - Australia
Posts: 7
|
Hi Juan and thanks,
Can I use multiples i.e Vlookup(B1, {2001,2003,3004,2012,"Bats" and what does the ,2,0, signify at the end of the Vlookup. Is there a limitation to how many records I can have in the Vlookup. I am not a VBA exponent but is that a suitable solution and relatively simple? Regards Bill T |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Check this example.
In the first one, there's no EXACT match, that's why using FALSE (or 0) returns N/A, in the second one, there is an EXACT match. To see the formula in the cells just click on the cells hyperlink The above image was automatically generated by [HtmlMaker V1.28] If you want FREE SOFT, click here and Colo will email the file to you This code was graciously allowed to be modified: by Ivan F Moala All credit to Colo |
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Location: Sydney - Australia
Posts: 7
|
HI Juan,
I have the following entered in C1 it finds the 2012 and correctly enters Bats, however the next line C2, which has 2013 is #N/A. =VLOOKUP(B1,{2012,"Bats",2013,"Bats"},2,0) What am I doing wrong? I have looked at the formating, all appears to be normal however I can not get rid of the #N/A Regards, Bill T |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
=VLOOKUP(B1,{2012,"Bats";2013,"Bats"},2,0) |
|
|
|
|
|
|
#8 |
|
New Member
Join Date: May 2002
Location: Sydney - Australia
Posts: 7
|
HI All,
Thanks for the help works fine - 5500 line items, 51 categories, and 10 groups. Is a large Vlookup table, so VBA may be needed for the future? Regards & Thanks Bill T |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|