Funtion IF, AND, OR

girlyg

New Member
Joined
Apr 28, 2011
Messages
2
Hello people,

I'm trying to make a list:
M
L
B
D
C

But what I want is that If I try to put M, L or B in the same column, it will show me and error like "Incorrect, Try again". And for example if i try to put M, D, C or any of the other combination it will send "OK", it doesn't have to be necessary in a message box, but it would be better.

I was using this:
=IF(OR(AND(A9:A11="M"),AND(A9:A11="L"),AND(A9:A11="B")), "Incorrect, Try Again","OK")

But when I try this it shows me Value!, what I want to know if this is right or do I have to use VBA (which I don't exactly remember how to use).

I don't think it's complicated, I just think I'm not sure how to write it :confused:

Thanks for your help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
This might work, however I am sure there's a more elegant / compact solution that I can't think of.

=IF(OR(AND(COUNTIF(A9:A11,"M"),COUNTIF(A9:A11,"L")),AND(COUNTIF(A9:A11,"M"),COUNTIF(A9:A11,"B")),AND(COUNTIF(A9:A11,"B"),COUNTIF(A9:A11,"L"))),"Incorrect, Try Again","OK")
 
Upvote 0
Hi

Your question is not clear. You don't say what you want in case a letter is repeated, or even if that's possible. For ex, the combination {"L","J","L"}, is it valid?

Please clarify.

Assuming letters do not repeat, try:

=IF(SUM(COUNTIF(A9:A11,{"M","L","B"}))>1,"Incorrect, Try Again","OK")
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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