+/- 1 when identifying pairs

mrphilippines1994

New Member
Joined
Dec 8, 2017
Messages
8
Hey guys - Need help here. kinda new here.

I need a formula to identify pairs with a +/- 1.

Example:

I'm looking for a pair with value of 100 but the only thing I have is 97,98,99 and 101. I need a formula where 100 will still be matched with the values 99 and 101.

Let me know if I'm still not clear. lol

cheers mate
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Will it return an address or what else? Or just a true value?
 
Last edited by a moderator:
Upvote 0
=IF(ISERROR(MATCH(B1,A:A,0)),IF(ISERROR(MATCH((B1-1),A:A,0)),0,IF(OR(INDIRECT("A"&MATCH((B1-1),A:A,0)+1)=(B1+1),INDIRECT("A"&MATCH((B1-1),A:A,0)-1)=(B1+1)),1,0)),1)*B1

Place your data to column A. Place our lookup value to B1 cell. Paste the formula above anywhere you like. It will return your lookup value if there is a match. Otherwise it will retun 0.
 
Last edited by a moderator:
Upvote 0
Hi, here is another option that you can try - same set-up as @Flashbond

=IF(SUM(COUNTIFS(A:A,B1+{-1,0,1})),B1,0)
 
Upvote 0
Hi, here is another option that you can try - same set-up as @Flashbond

=IF(SUM(COUNTIFS(A:A,B1+{-1,0,1})),B1,0)

I think your formula has a flow. Place numbers 97. 98. 99. 101, 104.

Your formula is returning TRUE when you lookup for 102 even it doesn't match a +/-1 pair.
 
Upvote 0
I think your formula has a flow. Place numbers 97. 98. 99. 101, 104.

Your formula is returning TRUE when you lookup for 102 even it doesn't match a +/-1 pair.

Maybe I'm not understanding, I thought it was simply - does a number exist that is either +1 / -1 or equal to the value being searched.

If there needs to be more than one match, then maybe this slight amendment.

=IF(SUM(COUNTIFS(A:A,B1+{-1,0,1})>1),B1,0)
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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