Hi Tom,
Thanks Tom
Thanks a lot
Your advice has saved me lot of time .But created another problem.Now
i have to covert my UDF to excel formula to meet my requirement .My
requirement is like this
I have two input
1.Job title
2.salary
From the JobTile i have to find the Job category from lookup table and
from Job category i have to find the salary range from another look
table and then apply the PERCENTILERANK fuction on that range and if it
falls below range it should give Below,and above if it is greater .Iam
attaching the code for the UDF i have written(hope ever one understands
my logic
)) .Can any one convert it to formula .Is it possible to do
my requirement with formula itself or do i have to write UDF?
Code:
--------------------
Function GetRank(rngJobTitle As Range, rngSalary As Range)
'Custom function to find the rank
Dim wsCatLookup As Worksheet
Dim rngTemp, rngSalRng As Range, rngResult As Range, rngCatRange As Range
Dim LowerLimit As Long, UpperLimit As Long
Dim strCategory As String, strFormula As String, strJobTitle As String, strTemp As String
Dim bReturn As Boolean
Set wsCatLookup = ThisWorkbook.Sheets("SalaryRange")
Set rngTemp = wsCatLookup.Range("A4", wsCatLookup.Range("C4").End(xlDown))
Set rngSalRng = wsCatLookup.Range("E3", wsCatLookup.Range("G4").End(xlDown))
strJobTitle = CStr(rngJobTitle.Value)
If Len(strJobTitle) Then
strCategory = WorksheetFunction.VLOOKUP(strJobTitle, rngTemp, 2, False)
End If
Set rngResult = GetRangeFromCategory(strCategory)
If IsEmpty(rngSalary.Value) Then
GetRank = ""
ElseIf (rngSalary.Value < rngResult.Cells(1, 1).Value) Then
GetRank = "Below"
ElseIf (rngSalary.Value > rngResult.Cells(1, 2).Value) Then
GetRank = "Above"
Else
GetRank = Application.WorksheetFunction.PercentRank(rngResult,rngSalary.Value, 3)
End If