Countif syntax

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,274
Office Version
  1. 365
Platform
  1. Windows
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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,222,384
Messages
6,165,669
Members
451,983
Latest member
Raph24

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