When using COUNTIF function in making my VB sub I faced a problem: COUNTIF returns either zero or number of cells in a range. Moreover, sometimes it returns correct numbers when I use another data.
Here is the code I use:
Sub CountifPerc()
Dim i As Integer
Dim MyArr() As Double
Set InitialRange = Range("A1:A250")
InitialRangeSize = InitialRange.Cells.Count
ReDim MyArr(InitialRangeSize - 1) As Double
For i = 1 To InitialRangeSize
MyArr(i - 1) = Application.WorksheetFunction.CountIf(InitialRange, "<=" & InitialRange(i).Value) / InitialRangeSize
Next i
End Sub
Could you, please, help me with this question?
UPD: I've found out that the problem occurs when I use non-integer data. Integer data works well.