PERCENTAGEIFS

Returns the percentage of numbers in a range that satisfy multiple conditions.
For instructions on how to add a function to a workbook refer to the page under Inserting Functions


'rgeValues - The range of values.
'sCondition - The condition you want to use.
'iDecimalPlaces - The number of decimal places you want the percentage returned as.

Public Function PERCENTAGEIFS( _
                           ByVal rgeValues As Range, _
                           ByVal sCondition As String, _
                           ByVal iDecimalPlaces As Integer) As Double

   PERCENTAGEIFS = VBA.Round((Application.WorksheetFunction.CountIf(rgeValues, sCondition) / _
                 Application.WorksheetFunction.Count(rgeValues)) * 100, iDecimalPlaces)

End Function
microsoft excel docs

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext