Sum or Count?

  • Thread starter Thread starter Bishop
  • Start date Start date
B

Bishop

I have a single column that contains multiple entries of 7 different ratings:
P, PG, PG13, R, NC17, X, Unrated. I'm trying to initialize a Summary
userform with the sum of each of these and assign these sums to a label for
each of the ratings. I thought about Sum or Count but I can't figure out the
best way to extract all the entries for each rating, get a total and assign
it to a variable. Any ideas?
 
If you want to use a formula:

="P = " & COUNTIF(A3:A15, "P")

I used rang A3:A15, but you can use whatever range the criteria is in.
CountIf
concatenated to each rating, i.e. "PG = ", PG13 = ", etc. will give you an
output
like P = 5, PG = 11, etc. You need a formula for each rating code in their
individual cells.
 
A Pivot table does this in no time. But you need it in code onto a userform?
If your entries are strictly limited and at all times properly spelled <g>,
this might be a start:

Sub test()
MsgBox Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A1000"),
"PG13")
End Sub

COUNTIF is the proper spreadsheet formula here if I understand you correct.

HTH. Best wishes Harald
 
Back
Top