I'm having some trouble getting my macro to use a countif funtion to display the frequency of scores in a given cell. This is part of a larger macro that I am currently working on to generate a report out of a given set of exported data.
When I try to run the code, it returns all zeros in the cells I have specified even though there is data in there that matches my criteria.
Please feel free if you like to critique this code as I am just starting out in programming and wanting to learn as much as possible.
Thanks in advance!
Here is a copy of the code:
Dim i As Integer
Dim ws_raw As Worksheet
Dim ws_rpt As Worksheet
Set ws_raw = Sheets("Raw Data")
Set ws_rpt = Sheets("Report")
If ws_raw.Range("H2") <> "" Then
i = WorksheetFunction.CountIf(Range("S2:CCC2"), "5")
ws_raw.Range("I2").Value = i
i = WorksheetFunction.CountIf(Range("S2:CCC2"), "6")
ws_raw.Range("J2").Value = i
i = WorksheetFunction.CountIf(Range("S2:CCC2"), "7")
ws_raw.Range("K2").Value = i
i = WorksheetFunction.CountIf(Range("S2:CCC2"), "8")
ws_raw.Range("L2").Value = i
Else
End If