Countif syntax

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Yep, another new query.:(

I require to check the synta of which function is right?

Function 1 -
Public Function showcount()
Range("D7") = Application.WorksheetFunction.CountIf(Range("C15:C"), 1)
Range("D8") = Application.WorksheetFunction.CountIf(Range("C15:C"), 2)
Range("D9") = Application.WorksheetFunction.CountIf(Range("C15:C"), 3)
Range("D10") = Application.WorksheetFunction.CountIf(Range("C15:C"), 4)
Range("D11") = Application.WorksheetFunction.CountIf(Range("C15:C"), 5)
Range("D12") = Application.WorksheetFunction.CountIf(Range("C15:C"), 6)
Range("D13") = Application.WorksheetFunction.CountIf(Range("C15:C"), 7)
End Function

Function 2- ...This is only for one cell i.e.- D9
Public Function test()
Dim ax As Long
ax = Range("C" & Rows.Count).End(xlUp).Row
If ax < 9 Then
ax = 9
Range("D9") = Application.WorksheetFunction.CountIf(Range("D9:D" & ax), "3")
End If
End Function
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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