Countif and VBA

countingapples

Board Regular
Joined
Feb 20, 2003
Messages
243
Can I use: {=sum(1/countif(data,data))} in the following code? If so, how do I do so?

Code:
With ActiveSheet.PivotTables("Unit Response Summary").PivotFields( _
        "Incident Type Class")
        .Orientation = xlDataField
        .Position = 1
    End With
ActiveSheet.PivotTables("Unit Response Summary").PivotFields("Count of Incident Type Class"). _
        Caption = "Count"

I need to count each instance once. Right now it is returning the counts for every instance. If there are 9 line items for one unique key, I don't want it to return 9, I want it to return 1.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
you can use

application.worksheetfunction.sum

and

application.worksheetfunction.countif

in your vba code.
 
Upvote 0
Hard not to when you are struggling with something that you just can't seem to get ahold of after such a long time.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top