PC Review


Reply
Thread Tools Rate Thread

count different instances in two columns

 
 
K7
Guest
Posts: n/a
 
      5th Jun 2006
Hello all,

I haven't been able to solve this...

I have two columns in the same sheet. I would like to extract (in another
sheet) all the unique elements of each column and count how many each data
is repeated. Any element can appear in both column. An example would be:

column 1 column 2

red red
red blue
blue green
yellow magenta


the result would be

red 3
blue 2
yellow 1
green 1
magenta 1


Sorry for my english and thanks to whoever can help me with this.


 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      5th Jun 2006
=COUNTIF(A:A,"red")+COUNTIF(B:B,"red")

etc.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"K7" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> I haven't been able to solve this...
>
> I have two columns in the same sheet. I would like to extract (in another
> sheet) all the unique elements of each column and count how many each data
> is repeated. Any element can appear in both column. An example would be:
>
> column 1 column 2
>
> red red
> red blue
> blue green
> yellow magenta
>
>
> the result would be
>
> red 3
> blue 2
> yellow 1
> green 1
> magenta 1
>
>
> Sorry for my english and thanks to whoever can help me with this.
>
>



 
Reply With Quote
 
Heather Heritage
Guest
Posts: n/a
 
      5th Jun 2006
If that method is ok, then COUNTIF(A:B,"red") will do it just as well -
however, I THINK the problem is in identifying all the unique values, then
summing them - perhaps the original questioner could clarify this? I had
thought pivot table to get the data, but it's in 2 columns which will cause
more problems - so my thoughts are now on a macro solution!
"Bob Phillips" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> =COUNTIF(A:A,"red")+COUNTIF(B:B,"red")
>
> etc.
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "K7" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello all,
> >
> > I haven't been able to solve this...
> >
> > I have two columns in the same sheet. I would like to extract (in

another
> > sheet) all the unique elements of each column and count how many each

data
> > is repeated. Any element can appear in both column. An example would be:
> >
> > column 1 column 2
> >
> > red red
> > red blue
> > blue green
> > yellow magenta
> >
> >
> > the result would be
> >
> > red 3
> > blue 2
> > yellow 1
> > green 1
> > magenta 1
> >
> >
> > Sorry for my english and thanks to whoever can help me with this.
> >
> >

>
>



 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      5th Jun 2006
On Mon, 5 Jun 2006 08:12:48 +0200, "K7" <(E-Mail Removed)> wrote:

>Hello all,
>
>I haven't been able to solve this...
>
>I have two columns in the same sheet. I would like to extract (in another
>sheet) all the unique elements of each column and count how many each data
>is repeated. Any element can appear in both column. An example would be:
>
>column 1 column 2
>
>red red
>red blue
>blue green
>yellow magenta
>
>
>the result would be
>
>red 3
>blue 2
>yellow 1
>green 1
>magenta 1
>
>
>Sorry for my english and thanks to whoever can help me with this.
>


This should work: Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr

Then assuming your data is on Sheet1!A2:B100

On sheet2

A2: =INDEX(UNIQUEVALUES(Sheet1!$A$2:$B$100,1),ROWS($1:1))
B2: =COUNTIF(Sheet1!$A$2:$B$100,A2)
Copy/drag down as far as required to encompass all of the unique values.




--ron
 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      5th Jun 2006
On Mon, 05 Jun 2006 07:30:12 -0400, Ron Rosenfeld <(E-Mail Removed)>
wrote:

>On Mon, 5 Jun 2006 08:12:48 +0200, "K7" <(E-Mail Removed)> wrote:
>
>>Hello all,
>>
>>I haven't been able to solve this...
>>
>>I have two columns in the same sheet. I would like to extract (in another
>>sheet) all the unique elements of each column and count how many each data
>>is repeated. Any element can appear in both column. An example would be:
>>
>>column 1 column 2
>>
>>red red
>>red blue
>>blue green
>>yellow magenta
>>
>>
>>the result would be
>>
>>red 3
>>blue 2
>>yellow 1
>>green 1
>>magenta 1
>>
>>
>>Sorry for my english and thanks to whoever can help me with this.
>>

>
>This should work: Download and install Longre's free morefunc.xll add-in from
>http://xcell05.free.fr
>
>Then assuming your data is on Sheet1!A2:B100
>
>On sheet2
>
>A2: =INDEX(UNIQUEVALUES(Sheet1!$A$2:$B$100,1),ROWS($1:1))
>B2: =COUNTIF(Sheet1!$A$2:$B$100,A2)
>Copy/drag down as far as required to encompass all of the unique values.
>
>
>
>
>--ron


I should also note that with this formula, you are limited to a maximum number
of 65535 elements in the array. If you have more than that, a different
approach can be devised.


--ron
 
Reply With Quote
 
Roger Govier
Guest
Posts: n/a
 
      5th Jun 2006
Hi Ron

This is not working for me.
It gives me a result of
blue 1
blue 1
green 1
magenta 1
red 1
red 2
yellow 1

It looks as though the formula is treating each column as separate in
terms of determining the uniques.
What am I doing wrong?
Windows XP Prof, Excel 2003

--
Regards

Roger Govier


"Ron Rosenfeld" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mon, 5 Jun 2006 08:12:48 +0200, "K7" <(E-Mail Removed)> wrote:
>
>>Hello all,
>>
>>I haven't been able to solve this...
>>
>>I have two columns in the same sheet. I would like to extract (in
>>another
>>sheet) all the unique elements of each column and count how many each
>>data
>>is repeated. Any element can appear in both column. An example would
>>be:
>>
>>column 1 column 2
>>
>>red red
>>red blue
>>blue green
>>yellow magenta
>>
>>
>>the result would be
>>
>>red 3
>>blue 2
>>yellow 1
>>green 1
>>magenta 1
>>
>>
>>Sorry for my english and thanks to whoever can help me with this.
>>

>
> This should work: Download and install Longre's free morefunc.xll
> add-in from
> http://xcell05.free.fr
>
> Then assuming your data is on Sheet1!A2:B100
>
> On sheet2
>
> A2: =INDEX(UNIQUEVALUES(Sheet1!$A$2:$B$100,1),ROWS($1:1))
> B2: =COUNTIF(Sheet1!$A$2:$B$100,A2)
> Copy/drag down as far as required to encompass all of the unique
> values.
>
>
>
>
> --ron



 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      5th Jun 2006
On Mon, 5 Jun 2006 13:28:10 +0100, "Roger Govier"
<(E-Mail Removed)> wrote:

>Hi Ron
>
>This is not working for me.
>It gives me a result of
>blue 1
>blue 1
>green 1
>magenta 1
>red 1
>red 2
>yellow 1
>
>It looks as though the formula is treating each column as separate in
>terms of determining the uniques.
>What am I doing wrong?
>Windows XP Prof, Excel 2003



Do a copy/paste of the exact formulas you are using. It works fine here, so I
suspect there's either a typo in your formula, or something about your data.

Looking at your results, I'd consider that some of your data has a trailing
character -- either a <space> or a <no-break space>. That could be the case if
you downloaded the source data from a web table, for example.


--ron
 
Reply With Quote
 
Roger Govier
Guest
Posts: n/a
 
      5th Jun 2006
Hi Ron
Of course. I copied the data from the OP and pasted with a Text to
columns split.
With correct data, the formula works exactly as described.
Thanks

--
Regards

Roger Govier


"Ron Rosenfeld" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mon, 5 Jun 2006 13:28:10 +0100, "Roger Govier"
> <(E-Mail Removed)> wrote:
>
>>Hi Ron
>>
>>This is not working for me.
>>It gives me a result of
>>blue 1
>>blue 1
>>green 1
>>magenta 1
>>red 1
>>red 2
>>yellow 1
>>
>>It looks as though the formula is treating each column as separate in
>>terms of determining the uniques.
>>What am I doing wrong?
>>Windows XP Prof, Excel 2003

>
>
> Do a copy/paste of the exact formulas you are using. It works fine
> here, so I
> suspect there's either a typo in your formula, or something about your
> data.
>
> Looking at your results, I'd consider that some of your data has a
> trailing
> character -- either a <space> or a <no-break space>. That could be
> the case if
> you downloaded the source data from a web table, for example.
>
>
> --ron



 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      5th Jun 2006
On Mon, 5 Jun 2006 16:05:49 +0100, "Roger Govier"
<(E-Mail Removed)> wrote:

>Hi Ron
>Of course. I copied the data from the OP and pasted with a Text to
>columns split.
>With correct data, the formula works exactly as described.
>Thanks



You're welcome. Thanks for letting me know.
--ron
 
Reply With Quote
 
K7
Guest
Posts: n/a
 
      5th Jun 2006
Thanks all of you. I did not imagine that I could have an answer to this
problem so quick! I hope I could help you sometime...

This UNIQUEVALUES... any idea of how it works? It works fine, but I'm
writting a macro and I'd rather prefer to depend of my own code only.

Best regards and thanks all.



"K7" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> Hello all,
>
> I haven't been able to solve this...
>
> I have two columns in the same sheet. I would like to extract (in another
> sheet) all the unique elements of each column and count how many each data
> is repeated. Any element can appear in both column. An example would be:
>
> column 1 column 2
>
> red red
> red blue
> blue green
> yellow magenta
>
>
> the result would be
>
> red 3
> blue 2
> yellow 1
> green 1
> magenta 1
>
>
> Sorry for my english and thanks to whoever can help me with this.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Instances Chad Wodskow Microsoft Excel Worksheet Functions 4 4th Mar 2010 08:29 PM
Count Instances of value in two columns KN Microsoft Excel Worksheet Functions 2 24th Oct 2007 03:54 AM
Count Instances of value in two columns KN Microsoft Excel Discussion 3 23rd Oct 2007 06:57 PM
count unique instances based on two columns omnicrondelicious@gmail.com Microsoft Excel Worksheet Functions 9 27th May 2007 01:49 AM
count instances of a name(s) Daren Microsoft Access Queries 3 7th Mar 2004 05:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 AM.