IF Statement for Range of options

BrianP1

New Member
Joined
Jun 4, 2018
Messages
12
Trying to find if this is possible. I have a list of names which I am trying to do If Statements on. I need the if statement to return a value if a specific cell equals one of the names on the list. The list contains 75 people so would need multiple if statements. Instead of doing an if statement for each name on the list, is there a way for the if statement to look at the entire list at once (using a range or something)?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Yes, that is possible with an IF and VLOOKUP/LOOKUP combination.
 
Upvote 0
Welcome to the board.

Sounds like you just need a VLOOKUP. Build a table with the names and values you want, then use the VLOOKUP to get the corresponding value:

ABCDE
1NameScoreNameScore
2Erica99Ann80
3Bob90
4Cathy55
5Dan45
6Erica99
7Frank75

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=VLOOKUP(A2,D2:E7,2,0)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
If you explain a little bit more about how your data is set up and what value you want to return, then yes. Though, you might take a look at what Eric has posted first and see if that is what you need.
 
Upvote 0
Welcome to the board.

Sounds like you just need a VLOOKUP. Build a table with the names and values you want, then use the VLOOKUP to get the corresponding value:

ABCDE
1NameScoreNameScore
2Erica99Ann80
3Bob90
4Cathy55
5Dan45
6Erica99
7Frank75

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=VLOOKUP(A2,D2:E7,2,0)

<tbody>
</tbody>

<tbody>
</tbody>

Thanks Eric. Unfortunately it is a little more complicated than that. I have a table of 50,000 rows of data that I need to check to see if a value in a collumn for each of the rows contains a sales rep name in a separate table of 75 names.
 
Upvote 0
Now it sounds more like you want a MATCH function. Try:

ABCD
1NameFound rep?Name
2EricaTRUEAnn
3AnnTRUEBob
4BobTRUECathy
5EricaTRUEDan
6DanTRUEErica
7MarkFALSEFrank
8EdFALSE
9

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=ISNUMBER(MATCH(A2,$D$2:$D$7,0))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



If this isn't what you want, then please show a sample of your sheet, and the expected results. You can use the HTML Maker in my signature to make sample sheets like I did, or just use the table tool on the Advanced menu.
 
Upvote 0
If you explain a little bit more about how your data is set up and what value you want to return, then yes. Though, you might take a look at what Eric has posted first and see if that is what you need.

Here is an example.

Need to see if Column C in Table 1 contains a name that is in the Table 2 Column A.

Table 1
A B C D E
Company X Deal 1234 Joe Smith $142.01 Product X
Company D. Deal 3364. Bob Hope $443.76 Product P
Company Q. Deal 2575. Rick Burns. $236.56. Product A


Table 2
A
Richard Watson
Bob Hope
Jane Doe
Joe Smith
Eric Poster
Trish Nixon
Erica Andrews
Liam Yon
 
Upvote 0
A
B
C
D
E
Company x
Deal 1234
Joe Smith
$142
Product X
Company D
Deal 3364
Bob Hope
$443
Product P
Company Q
Deal 2575
Rick Burns
$236
Product A

<tbody>
</tbody>




Table 2

A
B
Richard Watson
Thomas Preston
Bob Hope
Thomas Preston
Jane Doe
Thomas Preston
Joe Smith
Samuel Rogers
Eric Poster
Samuel Rogers
Trish Nixon
Walter Lin
Erica Andrews
Walter Lin

<tbody>
</tbody>


The code I need will be within the 1st table, looking at Column C to see if the name matches a value in Table 2 Column A. If it matches, it would return the value in Table 2 Column B. If there is no match, then I would like it to say "No".

Hope this is clearer.
 
Upvote 0
OK, back to the VLOOKUP:

ABCDEFGHIJ
1CompanyDealRepAmountProductAcct. ExecRepAcct. Exec
2Company xDeal 1234Joe Smith$142 Product XSamuel RogersRichard WatsonThomas Preston
3Company DDeal 3364Bob Hope$443 Product PThomas PrestonBob HopeThomas Preston
4Company QDeal 2575Rick Burns$236 Product ANoJane DoeThomas Preston
5Joe SmithSamuel Rogers
6Eric PosterSamuel Rogers
7Trish NixonWalter Lin
8Erica AndrewsWalter Lin
9

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet3

Worksheet Formulas
CellFormula
F2=IFERROR(VLOOKUP(C2,$H$2:$I$8,2,0),"No")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top