Counting Values in a Range

Joined
Jul 6, 2008
Messages
4
Reaction score
0
Hi,

I'm trying to count the number of "Yes" and "No" in a range using the worksheet function CountIf, but so far it isn't working...It says that there is a compile error and that I need to define an object on the "Set CountYes...." line, but I don't know what I'm missing!

Code:
Sub Count_Goal_Met() 
 
Dim Goal_Met_Column As Range
Dim CountYes As Integer
Dim CountNo As Integer
 
Set Goal_Met_Column = Application.InputBox(Prompt:="Please select the goal met range with your mouse.", Title:="Specify Goal Met Range", Type:=8)
Set CountYes = WorksheetFunction.CountIf(Range(Goal_Met_Column), "Yes")
Set CountNo = WorksheetFunction.CountIf(Range(Goal_Met_Column), "No")
 
MsgBox ("There are " & CountYes & " yeses and " & CountNo & " nos.")
 
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top