Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function RankThatSucker(theRank As Integer, DivisionRange As Range, DivisionNumber As Variant, CategoryRange As Range, CategoryType As Variant, DataRange As Range) As Double
- Dim WS As Worksheet, rCell As Range, Cat_Column As Integer, Div_Column As Integer, i As Long
- Set WS = Sheets(CategoryRange.Parent.Name)
- Set DataRange = Intersect(DataRange, WS.UsedRange)
- Cat_Column = CategoryRange.Cells(1, 1).Column
- Div_Column = DivisionRange.Cells(1, 1).Column
- Dim uData As Range
- ReDim prime_array(Application.WorksheetFunction.CountIf(Intersect(CategoryRange, WS.UsedRange), CategoryType)) As Double
- For Each rCell In DataRange.Cells
- If WS.Cells(rCell.Row, Div_Column).Value2 = DivisionNumber Then
- If WS.Cells(rCell.Row, Cat_Column).Value2 = CategoryType Then
- If IsNumeric(rCell) Then
- prime_array(i) = rCell.Value2
- i = i + 1
- End If
- End If
- End If
- Next rCell
- RankThatSucker = Application.WorksheetFunction.Large(prime_array(), theRank)
- End Function
Add Comment
Please, Sign In to add comment