Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Counting a subset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kent McPherson - 04 Dec 2007 18:58 GMT
I have data with multiple columns.  I want to count all items in column A =
"X" and with column B > 250.   I know how to do either condition but I need
to join the two.  Any help would be appreciated.  Thanks!
JLGWhiz - 04 Dec 2007 19:31 GMT
This could do it.

For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
 If Cells(i, 1) = "X" and Cells(i, 1).Offset(0, 1) > 250 Then
   'Do things
 End If
Next

> I have data with multiple columns.  I want to count all items in column A =
> "X" and with column B > 250.   I know how to do either condition but I need
> to join the two.  Any help would be appreciated.  Thanks!
excelent - 04 Dec 2007 19:35 GMT
=sumproduct((a1:a1000="X")*(b1:b1000>250))
change range to fit

"Kent McPherson" skrev:

> I have data with multiple columns.  I want to count all items in column A =
> "X" and with column B > 250.   I know how to do either condition but I need
> to join the two.  Any help would be appreciated.  Thanks!
Kent McPherson - 10 Dec 2007 14:16 GMT
Thanks, I've tried this formula but it doesn't give me the right answer.
For example, I should get an answer of 3 but it gives me 10.  If I change
either parameter to 1, I get the proper count but when it's together, I get
the wrong answer.  Is there any way to debug?  Suggestions?

> =sumproduct((a1:a1000="X")*(b1:b1000>250))
> change range to fit
[quoted text clipped - 6 lines]
>> need
>> to join the two.  Any help would be appreciated.  Thanks!
JLGWhiz - 04 Dec 2007 19:36 GMT
Sorry Kent, I forgot to put the counter on it.

Sub cnt()
Counter = 0
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
 If Cells(i, 1) = "X" and Cells(i, 1).Offset(0, 1) > 250 Then
   'Do things
   Counter = Counter + 1
 End If  
Next
MsgBox Counter
End Sub

> I have data with multiple columns.  I want to count all items in column A =
> "X" and with column B > 250.   I know how to do either condition but I need
> to join the two.  Any help would be appreciated.  Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.