# Determine existance of TWO numbers within four cells in one row

#### cbjexcel

##### New Member
I have a spreadsheet that consists of a series of four contiguous cells in one row that contain the numbers of 1 through 10 exclusively and without duplication (ie. 10, 1, 5, 9 OR 4, 2, 10, 1). I need a formula that determines whether two specified numbers (ie. 1 AND 5) exist within those four cells. If 'yes' return the number 1, if no return the number "0". This formula will be modified to determine other possibly combinations of numbers (ie. 2 AND 10 or 3 AND 4, etc) on other four cells.

### Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi

in E1

=IF(COUNTIF(A1:D1,1)*COUNTIF(A1:D1,5),1,0)

or if F1=1, G1=5

=IF(COUNTIF(A1:D1,F1)*COUNTIF(A1:D1,G1),1,0)

Regards

Last edited:
Hi again

another approach using MATCH.

In A1:D1 the 4 numbers, in F1:G1 numbers to be matched

In E1:

--(COUNT(INDEX(MATCH(F1:G1,A1:D1,0),))-1>0)

Regards

Here's another one...

Numbers in the range A1:D1

=--(SUM(COUNTIF(A1:D1,{1,5}))=2)

I appreciate your reply and your suggestions. I'll try them and see which is the easiest to use. You've made my efforts so much easier.

I've applied your suggestion and its doing exactly what I was hoping for . It's going to take some effort on my part to get this plugged in all of the right cells with the right number inquiries but once I've done this it'll self populate all of my data without any problems. THANKS

Replies
3
Views
211
Replies
4
Views
205
Replies
4
Views
139
Replies
1
Views
117
Replies
7
Views
163

1,206,949
Messages
6,075,810
Members
446,158
Latest member
octagonalowl

### 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.

### Which adblocker are you using?

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

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