Home » excel » excel – IF Function: if either 1, 2, 3, 4, 5 then copy to another sheet

# excel – IF Function: if either 1, 2, 3, 4, 5 then copy to another sheet

Questions:

I’m trying to create an if function that if one cell is equal to either 1, 2, 3,4 ,5, then it copies that entire line to another sheet in the same workbook. Is this possible? Or is it some kind of other formula that can do this?

if you want a formula to see if the value of a cell is a match to a list/Array of values you can use the following

``````=IF(ISNA(MATCH(A1,{1,2,3,4,5},0)),"Cell Does Not Contain One Of The Values",A1)
``````

when you enter this formula into a cell if A1 = 1,2,3,4 OR 5 then the cell you entered the formula in will return the value of A1. If A1 does not equal any of the values the cell you enter this formula in will then say “Cell Does Not Contain One Of The Values”

If you want to do this for an an entire row then you can LOCK in the first A1 reference and change the last one and drag this formula over.

So, in Sheet2 Cell B1 you can put:

``````    =IF(ISNA(MATCH('Sheet1'!\$A\$1,{1,2,3,4,5},0)),"Cell Does Not Contain One Of The Values",'Sheet1'!B1)
``````

and if the value in A1 is one of those value of B1 on Sheet2 will equal the value of B1 on Sheet1. Then if you drag the formula across the entire column it will adjust the results to the proper cells for you.

`=IF(OR(Sheet1.\$A\$2 = 1, Sheet1.\$A\$2 = 2, Sheet1.\$A\$2 = 3, Sheet1.\$A\$2 = 4, Sheet1.\$A\$2 = 5), Sheet1.A8, 0)K20`
In this case, the `value`, which you want to proof will be saved in `A2` and the `row 8` will be copied to the selected row if the value is an element of {1,2,3,4,5} and will be 0 if not.