ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting a subset (https://www.excelbanter.com/excel-programming/402209-counting-subset.html)

Kent McPherson[_2_]

Counting a subset
 
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

Counting a subset
 
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

"Kent McPherson" wrote:

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

Counting a subset
 
=sumproduct((a1:a1000="X")*(b1:b1000250))
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!




JLGWhiz

Counting a subset
 
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

"Kent McPherson" wrote:

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[_2_]

Counting a subset
 
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?

"excelent" wrote in message
...
=sumproduct((a1:a1000="X")*(b1:b1000250))
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!







All times are GMT +1. The time now is 10:17 PM.

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