ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Test 2 numbers (https://www.excelbanter.com/excel-worksheet-functions/219575-test-2-numbers.html)

Dave

Test 2 numbers
 
Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d

Ashish Mathur[_2_]

Test 2 numbers
 
Hi,

In cell C2, you can use the formula

=If(a1=b1,2,1)

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Dave" wrote in message
...
Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to
return
1 or if the numbers are the same 2


d



Gary''s Student

Test 2 numbers
 
=IF(A1=B1,2,1)
--
Gary''s Student - gsnu200832


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Mike H

Test 2 numbers
 
Hi,

A couple of ways

=DELTA(A1,B1)+1

or

=(A1=B1)*1+1

Mike



"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Mike H

Test 2 numbers
 
I should have mentioned that if you use DELTA and get a name error then

Tools|Addins and check the analysis toolpak

re-enter the formula

Mike

"Mike H" wrote:

Hi,

A couple of ways

=DELTA(A1,B1)+1

or

=(A1=B1)*1+1

Mike



"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Teethless mama

Test 2 numbers
 
=COUNTIF(A1:B1,A1)


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Dave

Test 2 numbers
 
Thank you

"Ashish Mathur" wrote:

Hi,

In cell C2, you can use the formula

=If(a1=b1,2,1)

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Dave" wrote in message
...
Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to
return
1 or if the numbers are the same 2


d



Dave

Test 2 numbers
 
Thank you

"Gary''s Student" wrote:

=IF(A1=B1,2,1)
--
Gary''s Student - gsnu200832


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Dave

Test 2 numbers
 
Thank you

"Mike H" wrote:

Hi,

A couple of ways

=DELTA(A1,B1)+1

or

=(A1=B1)*1+1

Mike



"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Dave

Test 2 numbers
 
Thank you

"Teethless mama" wrote:

=COUNTIF(A1:B1,A1)


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Ashish Mathur[_2_]

Test 2 numbers
 
You are welcome

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Ashish Mathur" wrote in message
...
Hi,

In cell C2, you can use the formula

=If(a1=b1,2,1)

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Dave" wrote in message
...
Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to
return
1 or if the numbers are the same 2


d



Ron Rosenfeld

Test 2 numbers
 
On Sat, 7 Feb 2009 04:27:02 -0800, Dave wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


=1+(A1=B1)
--ron

Ron Rosenfeld

Test 2 numbers
 
On Sat, 7 Feb 2009 04:38:01 -0800, Mike H
wrote:

=(A1=B1)*1+1


The *1 seems to be superfluous.

=(A1=B1)+1



--ron

Mike H

Test 2 numbers
 
Ron,

I had a mindset about changing false/true to 0 or 1 and then adding the 1
the OP wanted and failed to realise the +1 would do both jobs.

Thanks for pointing that out.

Mike

"Ron Rosenfeld" wrote:

On Sat, 7 Feb 2009 04:38:01 -0800, Mike H
wrote:

=(A1=B1)*1+1


The *1 seems to be superfluous.

=(A1=B1)+1



--ron


Shane Devenshire[_2_]

Test 2 numbers
 
Hi,

One advantage in using COUNTIF is that it will work for Text, Numbers, or
Dates

One advantage in using =1+(A1=A2) or DELTA is that the cells don't need to
be adjactent, but both of these don't work for text.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


T. Valko

Test 2 numbers
 
using =1+(A1=A2) or DELTA
but both of these don't work for text.


=1+(A1=A2)

Does work with text.

--
Biff
Microsoft Excel MVP


"Shane Devenshire" wrote in
message ...
Hi,

One advantage in using COUNTIF is that it will work for Text, Numbers, or
Dates

One advantage in using =1+(A1=A2) or DELTA is that the cells don't need to
be adjactent, but both of these don't work for text.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to
return
1 or if the numbers are the same 2


d




Ron Rosenfeld

Test 2 numbers
 
On Sat, 7 Feb 2009 09:34:01 -0800, Shane Devenshire
wrote:

One advantage in using =1+(A1=A2) or DELTA is that the cells don't need to
be adjactent, but both of these don't work for text.


I'm not sure about your English. Maybe the difference between GB and the
colonies?

When you write "both of these don't work for text", some would take that to
mean that "neither" of these equations work for text.

I believe it would be useful to point out that the first equation works for
text or numbers, and the second only works for numbers.

And to be complete, the first is not case-sensitive when applied to text. A
case-sensitive variation, which would work for both text and numbers, would be:

=exact(a1,a2)+1

--ron

Mike H

Test 2 numbers
 
Shane,

You missed a major disadvantage of DELTA is that it can only take 2
arguments and would become more trouble than it's worth with the fiddling
about you'd have to do when trying to evaluate more than 2. The only reason I
offered it was because th OP specified 2 numbers.

We'll disagree about whether =(A1=B1)+1 can handle text, I remain of the
opinion it can :)

Mike




"Shane Devenshire" wrote:

Hi,

One advantage in using COUNTIF is that it will work for Text, Numbers, or
Dates

One advantage in using =1+(A1=A2) or DELTA is that the cells don't need to
be adjactent, but both of these don't work for text.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d


Shane Devenshire[_2_]

Test 2 numbers
 
Hi all

We don't have to disagree on whether the first one will work with text, I
was a little fast on the draw, it does work for text.

And I like the additional point about the limits of DELTA. But I was glad
to see someone find a use for DELTA, I sure there are others but it usually
seems a little longer that other solutions.

Cheers,
Shane Devenshire


"Mike H" wrote:

Shane,

You missed a major disadvantage of DELTA is that it can only take 2
arguments and would become more trouble than it's worth with the fiddling
about you'd have to do when trying to evaluate more than 2. The only reason I
offered it was because th OP specified 2 numbers.

We'll disagree about whether =(A1=B1)+1 can handle text, I remain of the
opinion it can :)

Mike




"Shane Devenshire" wrote:

Hi,

One advantage in using COUNTIF is that it will work for Text, Numbers, or
Dates

One advantage in using =1+(A1=A2) or DELTA is that the cells don't need to
be adjactent, but both of these don't work for text.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Dave" wrote:

Hello,

two number in (say) a1 & b1

In another cell If the numbers are different how can i get Excel to return
1 or if the numbers are the same 2


d



All times are GMT +1. The time now is 11:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com