ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formula to count values in two columns (https://www.excelbanter.com/excel-discussion-misc-queries/107329-formula-count-values-two-columns.html)

JBurlage

Formula to count values in two columns
 
Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



Marcelo

Formula to count values in two columns
 
hi,

=sumproduct(--(a2:a1000="new")*(b2:B1000="critical"))

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



Kevin B

Formula to count values in two columns
 
You can use the following custom function to get your result:

Press ALT + F11 to open the VBE and then click INSERT on the menu and select
MODULE. You can copy and paste everthing from Function ... down to End
Function.

Using your example and assuming that the first row was row 1, the formula
would be entered =CountNewCrit(A1:B4)

Function CountNewCrit(CellAddress As Range) As Long


Dim r As Range
Dim l As Long
Dim lngRows As Long
Dim intCount As Integer

Set r = CellAddress
lngRows = r.Rows.Count

For l = 1 To lngRows
If Cells(l, 1) = "New" And _
Cells(l, 2) = "Critical" Then
intCount = intCount + 1
End If
Next l

Exit_Count:

Set r = Nothing
CountNewCrit = intCount
Exit Function

End Function


--
Kevin Backmann


"JBurlage" wrote:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



JBurlage

Formula to count values in two columns
 
Marcelo - I tried it and it does not work. I get a count of 0.

"Marcelo" wrote:

hi,

=sumproduct(--(a2:a1000="new")*(b2:B1000="critical"))

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



Marcelo

Formula to count values in two columns
 
hi,

strange, it works here, could you type your formula?

--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Marcelo - I tried it and it does not work. I get a count of 0.

"Marcelo" wrote:

hi,

=sumproduct(--(a2:a1000="new")*(b2:B1000="critical"))

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



GurlRossGurl

Formula to count values in two columns
 
Insert column C...enter =concatenate(a1,"-",b1), drag down all rows...insert
column d...countif(a1:b4,c1)....run down all rows. Clean up repeats as
needed.

"JBurlage" wrote:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!



JBurlage

Formula to count values in two columns
 
Hi Marcelo - I did a copy and paste from this posting and it would not work,
so I typed it in and now it is working!! Thanks so much for your help. I
appreciate the time and effort you took to help me out.
Regards from Wisconsin (USA)

"Marcelo" wrote:

hi,

strange, it works here, could you type your formula?

--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Marcelo - I tried it and it does not work. I get a count of 0.

"Marcelo" wrote:

hi,

=sumproduct(--(a2:a1000="new")*(b2:B1000="critical"))

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"JBurlage" escreveu:

Microsoft Excel 2000:
Is it possible to count values from two columns. I know that to count
values from one column the formula is =COUNTIF(B2:B20,"NEW"), but I need to
count a value from a second column also. For example:
Column A Column B
NEW critical
NEW critical
CLOSED major
NEW major

I need a formula that will count the value for "NEW" in Column A that are
"critical" in Column B. The count for this example should be 2. The count
for NEW - major should be 1 and CLOSED - major should be 1. Can anyone help?
THANKS!!




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

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