We all knows that how we can use “Countif” function in Excel and how it will work. Now in this article, we are going to learn how to use COUNTIF function in VBA.
Q): I am wondering how I can count all the cells that contain greater than 50 in column A through macros.
We need to follow the below steps:
Range(“B10″).Value = Application.WorksheetFunction.Countif(Range(“A2:A8″), “>” & 50)
In above snapshot with VBA code you will only see the result not the formula in cell B10. In this way we can use COUNTIF in VBA code with one criteria.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.