breynolds0431
Active Member
- Joined
- Feb 15, 2013
- Messages
- 303
- Office Version
- 365
- 2016
- Platform
- Windows
Hi. I have a userform that will count occurrences from a sheet based on a few factors, most notably being a date range. The below has a date range of one week in the past to current date. The counts are working as they should. However, I was trying to find a way to rank these countifs. The countifs results currently range from 1 up to 4. The error that's returned is "unable to get the percentrank property of the worksheetfunction class".
Any ideas on how to get this to work in the below or another way to "rank" the countifs results?
Any ideas on how to get this to work in the below or another way to "rank" the countifs results?
VBA Code:
With Me
.tbL1AsgCnt1.Value = Format(WorksheetFunction.CountIfs(rnpr, "", Grant, "<>Denied", assDt, ">=" & Date - 7, assDt, "<=" & Date, L1All, Aud1), "#,##0")
.tbL1AsgCnt2.Value = Format(WorksheetFunction.CountIfs(rnpr, "", Grant, "<>Denied", assDt, ">=" & Date - 7, assDt, "<=" & Date, L1All, Aud2), "#,##0")
.tbL1AsgCnt3.Value = Format(WorksheetFunction.CountIfs(rnpr, "", Grant, "<>Denied", assDt, ">=" & Date - 7, assDt, "<=" & Date, L1All, Aud3), "#,##0")
.tbL1AsgCnt4.Value = Format(WorksheetFunction.CountIfs(rnpr, "", Grant, "<>Denied", assDt, ">=" & Date - 7, assDt, "<=" & Date, L1All, Aud4), "#,##0")
.tbL1AsgCnt5.Value = Format(WorksheetFunction.CountIfs(rnpr, "", Grant, "<>Denied", assDt, ">=" & Date - 7, assDt, "<=" & Date, L1All, Aud5), "#,##0")
Dim arr: arr = Array(.tbL1AsgCnt1.Value, .tbL1AsgCnt2.Value, .tbL1AsgCnt3.Value, .tbL1AsgCnt4.Value, .tbL1AsgCnt5.Value)
.tbL1Shr1.Value = Format(1 - WorksheetFunction.PercentRank(arr, .tbL1AsgCnt1.Value), "#0%")
.tbL1Shr2.Value = Format(1 - WorksheetFunction.PercentRank(arr, .tbL1AsgCnt2.Value), "#0%")
.tbL1Shr3.Value = Format(1 - WorksheetFunction.PercentRank(arr, .tbL1AsgCnt3.Value), "#0%")
.tbL1Shr4.Value = Format(1 - WorksheetFunction.PercentRank(arr, .tbL1AsgCnt4.Value), "#0%")
.tbL1Shr5.Value = Format(1 - WorksheetFunction.PercentRank(arr, .tbL1AsgCnt5.Value), "#0%")
End With