#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default sumif countif thing?


Hi,

I have been trying to figure this out with no luck. I am trying to
count the number of occurences that "textvalue1" appears on the same
row with "textvalue2". Both "textvalue1" and "textvalue2" appear in
random areas of a cell range (c2:n999). Essentially I would like to do
something like this:

=COUNTIF(c2:n999,"textvalue1")AND IF
=COUNTIF(c2:n999,"textvalue2")

and then display the number of occurences that both textvalue1 and
textvalue2 appear in the same row together? Is this possible with a
cell range like this or should I just stop.

Thanks.


--
5dolla
------------------------------------------------------------------------
5dolla's Profile: http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default sumif countif thing?

Try this UDF (as I can't think of a formula solution!):

Place in required cell:

=countxx(C2:N999,"Textvalue1","Textvalue2")

Put code in general module

==Alt + F11 to open Visual Basic Editor
== right click on VBA project (for your w/book) and Insert==module
Copy/paste code below

HTH

-------------------------------------------------------------------------------

Function countxx(ByRef rng As Range, ByVal fval1 As String, ByVal fval2 As
String) As Long
n = 0
For r = 1 To rng.Rows.Count
n1 = Application.Match(fval1, Range(rng(r, 1), rng(r,
rng.Columns.Count)), 0)
n2 = Application.Match(fval2, Range(rng(r, 1), rng(r,
rng.Columns.Count)), 0)
If Not IsError(n1) Then
If Not IsError(n2) Then
n = n + 1
End If
End If
Next r
countxx = n
End Function

"5dolla" wrote:


Hi,

I have been trying to figure this out with no luck. I am trying to
count the number of occurences that "textvalue1" appears on the same
row with "textvalue2". Both "textvalue1" and "textvalue2" appear in
random areas of a cell range (c2:n999). Essentially I would like to do
something like this:

=COUNTIF(c2:n999,"textvalue1")AND IF
=COUNTIF(c2:n999,"textvalue2")

and then display the number of occurences that both textvalue1 and
textvalue2 appear in the same row together? Is this possible with a
cell range like this or should I just stop.

Thanks.


--
5dolla
------------------------------------------------------------------------
5dolla's Profile: http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default sumif countif thing?


OMG!!! That's totally genius and you probably just whipped that off the
top of your head, frickin' amazing.

Thank-you soooooo much Toppers. It's a good thing your not here b/c I
would have to kiss you............you totally rule! :)


--
5dolla
------------------------------------------------------------------------
5dolla's Profile: http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default sumif countif thing?

This may work, if you don't want to use VBA:
=SUM(COUNTIF(OFFSET(C1,ROW(INDIRECT("1:998")),0,1, 12),"=textvalue1")*COUNTIF(OFFSET(C1,ROW(INDIRECT( "1:998")),0,1,12),"=textvalue2"))

The formula has to be array-entered (hold down the control and shift keys
then press enter)

"5dolla" wrote in
message ...

Hi,

I have been trying to figure this out with no luck. I am trying to
count the number of occurences that "textvalue1" appears on the same
row with "textvalue2". Both "textvalue1" and "textvalue2" appear in
random areas of a cell range (c2:n999). Essentially I would like to do
something like this:

=COUNTIF(c2:n999,"textvalue1")AND IF
=COUNTIF(c2:n999,"textvalue2")

and then display the number of occurences that both textvalue1 and
textvalue2 appear in the same row together? Is this possible with a
cell range like this or should I just stop.

Thanks.


--
5dolla
------------------------------------------------------------------------
5dolla's Profile:
http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default sumif countif thing?


Thanks Jack Sheet, I will definitely give that a shot in my next
worksheet, I have 3 moe that I have to perform this on.

There seems to be so many short formulas to do more complicated things
than what I'm doing, it's wierd that the formulas to count the number
of rows that a value occurs multiple times would require so much, but
screw it, it works so I'm happy and grateful beyond words that I don't
have to sit and manually do a find then count the occurrences.

You folk are FN brilliant!

Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you
Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you


--
5dolla
------------------------------------------------------------------------
5dolla's Profile: http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default sumif countif thing?

Thanks for the feedback.

I would use Jack's solution as it uses standard functions (... so thanks
also to you Jack for filling in another gap in my knowledge).

"5dolla" wrote:


Thanks Jack Sheet, I will definitely give that a shot in my next
worksheet, I have 3 moe that I have to perform this on.

There seems to be so many short formulas to do more complicated things
than what I'm doing, it's wierd that the formulas to count the number
of rows that a value occurs multiple times would require so much, but
screw it, it works so I'm happy and grateful beyond words that I don't
have to sit and manually do a find then count the occurrences.

You folk are FN brilliant!

Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you
Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you


--
5dolla
------------------------------------------------------------------------
5dolla's Profile: http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default sumif countif thing?

I would not be surprised if there isn't a much more elegant solution than
mine. Someone will doubtless post one

"5dolla" wrote in
message ...

Thanks Jack Sheet, I will definitely give that a shot in my next
worksheet, I have 3 moe that I have to perform this on.

There seems to be so many short formulas to do more complicated things
than what I'm doing, it's wierd that the formulas to count the number
of rows that a value occurs multiple times would require so much, but
screw it, it works so I'm happy and grateful beyond words that I don't
have to sit and manually do a find then count the occurrences.

You folk are FN brilliant!

Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you
Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you Thank-you


--
5dolla
------------------------------------------------------------------------
5dolla's Profile:
http://www.excelforum.com/member.php...o&userid=36493
View this thread: http://www.excelforum.com/showthread...hreadid=562529



  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default sumif countif thing?


Hi Jack,

I think there's a potential problem with your solution. If textvalue1
appears twice in a single row in which textvalue 2 also appears that
will be counted twice.

To combat that you could use this formula

=COUNT(1/(FREQUENCY(IF(C2:N999="textvalue1",ROW(C2:N999)),R OW(C2:C999)-ROW(C$2)+1)*(FREQUENCY(IF(C2:N999="textvalue2",ROW (C2:N999)),ROW(C2:C999)-ROW(C$2)+1))))

confirmed with CTRL+SHIFT+ENTER


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=562529

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default sumif countif thing?

Good Catch.
My Bad.

My solution could have been changed only very slightly to correct for that:

=SUM((COUNTIF(OFFSET(C1,ROW(INDIRECT("1:998")),0,1 ,12),"=textvalue1")0)*(COUNTIF(OFFSET(C1,ROW(INDI RECT("1:998")),0,1,12),"=textvalue2")0))

But your solution is more elegant even so.

Apologies if this has been posted multiple times.


"daddylonglegs"
wrote in message
news:daddylonglegs.2b5t6v_1153257008.7595@excelfor um-nospam.com...

Hi Jack,

I think there's a potential problem with your solution. If textvalue1
appears twice in a single row in which textvalue 2 also appears that
will be counted twice.

To combat that you could use this formula

=COUNT(1/(FREQUENCY(IF(C2:N999="textvalue1",ROW(C2:N999)),R OW(C2:C999)-ROW(C$2)+1)*(FREQUENCY(IF(C2:N999="textvalue2",ROW (C2:N999)),ROW(C2:C999)-ROW(C$2)+1))))

confirmed with CTRL+SHIFT+ENTER


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile:
http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=562529



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forget SUMIF, COUNTIF and VLOOKUP Pierre Leclerc Excel Worksheet Functions 16 April 27th 23 11:51 AM
How do I set up a countif, or sumif that is multiconditional? Mr. Yanni Excel Worksheet Functions 9 June 21st 06 09:17 AM
problems with sumif and countif Simon Shaw Excel Discussion (Misc queries) 6 July 23rd 05 10:02 PM
Reference Cells with Sumif or Countif GK New Users to Excel 1 May 3rd 05 06:21 PM
Countif, Sumif, If - help! Angel160 Excel Worksheet Functions 2 November 3rd 04 05:23 PM


All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"