If Equal to this or this

if(or)
if cell equals one of multiple values
excel if cell equals a or b
if cell equals this
excel if one cell equals another then return another cell
if cell equals text then
if any excel
excel if statement multiple conditions range

I'm sure this is a simple answer, I just can't figure it out!

I need to check whether a variable is equal to multiple things:

if ((dls == '10:0') && (dls == '10:3') && (dls == '11:0') && (dls == '11:3')){
    stamp = 'PM';
};

Test Page: http://pmf.v5.cloudsvr.com.au/-artists/axle

You'll see the alert firing, and DLS == 11:3 in the alert, but stamp still equals AM not PM.

Thanks for any help.

*EDIT: I was using the wrong operators! *

if ((dls == '10:0') || (dls == '10:3') || (dls == '11:0') || (dls == '11:3')){
        stamp = 'PM';
};

You want || operator, Your condition will not be true as using && The if statement with && requires all the given conditions to be true which means dls should have 10:0, 10:3, 11:0 and 11:3 values in variable at a time but variable can have one of those at a time.

Change

if ((dls == '10:0') && (dls == '10:3') && (dls == '11:0') && (dls == '11:3')){
    stamp = 'PM';
};

To

if ((dls == '10:0') || (dls == '10:3') || (dls == '11:0') || (dls == '11:3')){
    stamp = 'PM';
};

Excel formula: If this AND that OR that, If you want to do something specific when a cell equals this or that (i.e. is equal to X or Y, etc.) you can use the IF function in combination with the OR function to run � If you want to do something specific when a cell equals this or that (i.e. is equal to X or Y, etc.) you can use the IF function in combination with the OR function to run a test, then take one action if the r esult is TRUE, and (optionally) do

Use || instead of &&

if ((dls == '10:0') || (dls == '10:3') || (dls == '11:0') || (dls == '11:3')){
    stamp = 'PM';
};

dls cannot be all those value.. it is going to be either of those values.. so you need to use || (or operator) instead of && (and operator)

Excel formula: If cell is x or y and z, If you want to do something specific when a cell equals this or that (i.e. is equal to X or Y, etc.) you can use the IF function in combination with the OR function to run � Equal definition: If two things are equal or if one thing is equal to another, they are the same in size, | Meaning, pronunciation, translations and examples

I think you may have meant to use || (OR) instead of && (AND):

if ((dls == '10:0') || (dls == '10:3') || (dls == '11:0') || (dls == '11:3')){
    stamp = 'PM';
};

Using IF with AND, OR and NOT functions, IF A7 (“Blue”) is NOT equal to “Red”, then return TRUE, otherwise return FALSE. Note that all of the examples have a closing parenthesis after their respective� in B2 is greater than or equal to 10, or Unit Price in C2 is greater than or equal to $5. So, you use the OR function to check both conditions, and if the result is TRUE, decrease the total amount by 10% (B2*C2*0.9), otherwise return the full price (B2*C2):

Firstly you are using the wrong operator .. Try using || instead of &&

You can try this approach too

var arr = ['10:0' , '10:3' , '11:0' , '11:3']
var dls = '10:1';

if ( arr.indexOf(dls) != -1){
    stamp = 'PM';
}
else{
   alert('Not PM')
}

If cell equals value from list, I recommend using the regular formula above, this array formula checks if cell B3 is equal to any of the values in E3:E5, the IF function returns� Note: you can use the following comparison operators: = (equal to), > (greater than), (less than), >= (greater than or equal to), = (less than or equal to) and > (not equal to). 2. Always enclose text in double quotation marks. 3a. The formula below calculates the progress between two points in time. 3b.

Try this:

Live Demo: http://jsfiddle.net/oscarj24/MS8V8/1/

val = $.grep(["10:0", "10:3", "11:0", "11:3"], function(n){ if(n === dls) return n; });
if(val[0] === dls) stamp = "PM";

alert(stamp);

Logical operators in Excel: equal to, not equal to, greater than, less , The formula returns TRUE if a value in cell A1 is less than or equal to the values in cell B1; FALSE otherwise. The screenshot below demonstrates� Example 1. Using the "Equal to" operator with dates. You might be surprised to know that the Equal to logical operator cannot compare dates as easily as numbers. For example, if the cells A1 and A2 contain the date "12/1/2014", the formula =A1=A2 will return TRUE exactly as it should.

Comparison Operators, Use comparison operators in Excel to check if two values are equal to each other, if one value is greater than another value, if one value is less than another� The results of this example show that, for the first test to be true, cell B3 has to equal the number 3. From there, the “value_if_true” for the initial IF uses a second, nested IF statement to make a second test (whether C3, C4, C5, or C6 contain the number 4). This gives you two potential “value_if_false” results (a 0 or a 1).

Excel: if cell 1 contains X or Y or Z, then cell 2 should equal W , You can try adding this formula to B1: =IF(OR(A1="X";A1="Y";A1="Z");"W";IF(OR( A1="G";A1="H";A1="J");"W";"")). The first part checks if A1 is� If we wanted to include just the valid (non-missing) observations that are greater than or equal to 4, we can do the following to tell Stata we want only observations where rep78 >= 4 and rep78 is not missing. list if rep78 >= 4 & !missing(rep78) make price mpg rep78 foreign 5.

If cell is this OR that, If you want to do something specific when a cell equals this or that (i.e. is equal to X or Y, etc.) you can use the IF function in combination with the OR function to�

Comments
  • My favorite part is that the question is titled "equal to this OR this" but you used the AND operator. :D
  • I didn't know it even existed using || :( now I do though! lol
  • I knew it had to be something so simple! Thankyou