A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Finding matches in two columns



 
 
Thread Tools Display Modes
  #1  
Old April 25th, 2010, 11:21 PM posted to microsoft.public.excel.worksheet.functions
Erik
external usenet poster
 
Posts: 110
Default Finding matches in two columns

I have two columns of years. Column A has 27 years from 1911 to 2007
indicating a particular year a house was built. Column B has all years from
1800 to 2009 use to plot a graph. In column C I want to find if any of the
years from 1800 through 2009 matchs one of the 27 years in column A and
return a 1 if that year matches or a 0 if it does not. With the results in
column C I can graph all years on the x axis and which one of them had a
house built.
Erik (a Word and Excel 2007 user)
  #2  
Old April 25th, 2010, 11:55 PM posted to microsoft.public.excel.worksheet.functions
Max
external usenet poster
 
Posts: 8,574
Default Finding matches in two columns

One way using COUNTIF
In C2: =IF(B2="","",IF(COUNTIF(A:A,B2),1,0))
Copy down to the last row of data in col B. Joy? hit the YES below
--
Max
Singapore
---
"Erik" wrote:
I have two columns of years. Column A has 27 years from 1911 to 2007
indicating a particular year a house was built. Column B has all years from
1800 to 2009 use to plot a graph. In column C I want to find if any of the
years from 1800 through 2009 matchs one of the 27 years in column A and
return a 1 if that year matches or a 0 if it does not. With the results in
column C I can graph all years on the x axis and which one of them had a
house built

  #3  
Old April 26th, 2010, 12:51 AM posted to microsoft.public.excel.worksheet.functions
Erik
external usenet poster
 
Posts: 110
Default Finding matches in two columns

Max, You are a genius and many thanks. Would you also be so kind to explain
what is going on using IF and COUNTIF? Thanks,
Erik
--
Erik (a Word 2007 user)


"Max" wrote:

One way using COUNTIF
In C2: =IF(B2="","",IF(COUNTIF(A:A,B2),1,0))
Copy down to the last row of data in col B. Joy? hit the YES below
--
Max
Singapore
---
"Erik" wrote:
I have two columns of years. Column A has 27 years from 1911 to 2007
indicating a particular year a house was built. Column B has all years from
1800 to 2009 use to plot a graph. In column C I want to find if any of the
years from 1800 through 2009 matchs one of the 27 years in column A and
return a 1 if that year matches or a 0 if it does not. With the results in
column C I can graph all years on the x axis and which one of them had a
house built

  #4  
Old April 26th, 2010, 03:01 AM posted to microsoft.public.excel.worksheet.functions
Max
external usenet poster
 
Posts: 8,574
Default Finding matches in two columns

This is the base IF formula: IF(COUNTIF(A:A,B2),1,0)

COUNTIF(A:A,B2) returns the number of times that the value in B2 is found
within col A. If B2 is found once, you'd get 1 as the return, 2 if twice and
so on.

Then .. the above used within the IF construct: IF(COUNTIF(A:A,B2),1,0)
the IF will evaluate any number* greater than zero as TRUE, zero as FALSE
*ie the number returned by the COUNTIF
--
Max
Singapore
---
"Erik" wrote:
Max, You are a genius and many thanks. Would you also be so kind to explain
what is going on using IF and COUNTIF? Thanks,
Erik
--
Erik (a Word 2007 user)

  #5  
Old April 26th, 2010, 03:32 AM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default Finding matches in two columns

the IF will evaluate any number* greater than zero
as TRUE, zero as FALSE
*ie the number returned by the COUNTIF


That's correct in the context of this particular application.

To be more specific...

IF will evaluate *any number other than 0* as TRUE, zero as FALSE. Text will
return an error.

=IF(-1 = TRUE
=IF(0 = FALSE
=IF(0.00000000025 = TRUE
=IF(-0.03897 = TRUE
=IF(1E100 = TRUE
=IF("text" = #VALUE!

--
Biff
Microsoft Excel MVP


"Max" wrote in message
...
This is the base IF formula: IF(COUNTIF(A:A,B2),1,0)

COUNTIF(A:A,B2) returns the number of times that the value in B2 is found
within col A. If B2 is found once, you'd get 1 as the return, 2 if twice
and
so on.

Then .. the above used within the IF construct: IF(COUNTIF(A:A,B2),1,0)
the IF will evaluate any number* greater than zero as TRUE, zero as FALSE
*ie the number returned by the COUNTIF
--
Max
Singapore
---
"Erik" wrote:
Max, You are a genius and many thanks. Would you also be so kind to
explain
what is going on using IF and COUNTIF? Thanks,
Erik
--
Erik (a Word 2007 user)



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.