Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# If statement with multiple values

Posted on 2016-09-20
Medium Priority
49 Views
Hello,

how should I write if statement for the following conditions:
if B is equals 25, if B is equals 41, if B equals 75, then return "correct" otherwise "incorrect"

thanks,
0
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2
• 2

LVL 33

Expert Comment

ID: 41806875
You can use the OR operator:

=IF(OR(B2=25,B2=41,B2=75),"Correct","Incorrect")
0

Author Comment

ID: 41806890
it did not work

this is my formula:

=IF(OR(K=27.92,K=42.97,K=75.96,K=127.31,K=230.82),"correct","Incorrect")
0

LVL 49

Expert Comment

ID: 41806894
Or in VBA...

``````Select Case B
Case 25, 41, 75
Msgboc "correct"
Case Else
Msgbox "incorrect"
End Select
``````
0

LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 41806896
You can't just use "K", it has to be a cell address like K2, or K99.
0

Author Comment

ID: 41806897
0

LVL 33

Expert Comment

ID: 41806908
Dare I suggest you have accepted the wrong solution???
0

LVL 49

Expert Comment

ID: 41806916
Dare I suggest you have accepted the wrong solution???
Yes I agree. Rob should get the points.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calculâ€¦
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
###### Suggested Courses
Course of the Month12 days, 2 hours left to enroll