PDA

View Full Version : Response Time UDF needs to be modified



rajkumar
12-01-2009, 11:28 AM
Hi VBAXians,

i need help in modifying a custom function.

here i have

Function RTTAIL(Group As Range, RT As Range) As String
If IsEmpty(RT) Then RTTAIL = "Blank data": Exit Function
Select Case Group.Value
Case "SFIDA", "MALTA", "DP180F": Limit = 2
Case "DC12", "FUJHIN", "OLYMPIA", "XES PSG": Limit = 4
Case Else: RTTAIL = Empty: Exit Function
End Select
If RT.Value > Limit Then RTTAIL = "Tail" Else RTTAIL = "Not a Tail"
End Function


i am calculating response time for each group based on limits assigned to them. Now my requirement is, i need to get result as RT not Met if the RT.value is greater than Limit but less than 1.5 times of Limit. And should get RT Tail if RT.value is greater than 1.5 times of Limit.

example : if my RT.value is 2.5 then it is greater than Limit but less than 1.5 times of Limit ( Limit x 1.5 times = 2 x 1.5 = 3 ) so i should get RT Not Met. this logic goes for each case in select case.

not knowing how to modify the function :doh: please help : pray2:
raj

Bob Phillips
12-01-2009, 11:39 AM
That is about as clear as the mud surrounding us in these waterlogged days.

ANd nowhere do I see Limit being assigned a value.

rajkumar
12-01-2009, 11:50 AM
I am attaching a sample workbook here
to make things clear

Paul_Hossler
12-01-2009, 12:01 PM
I don't see Limit DIMed anywhere so I put it in the Sub. Some logic like this might help.

The case where the value is < LIMIT did not seem to be addressed

Option Explicit
Function RTTAIL(Group As Range, RT As Range) As String
Dim Limit As Long

If IsEmpty(RT) Then
RTTAIL = "Blank data"
Exit Function
End If
Select Case Group.Value
Case "SFIDA", "MALTA", "DP180F"
Limit = 2
Case "DC12", "FUJHIN", "OLYMPIA", "XES PSG"
Limit = 4
Case Else
RTTAIL = Empty
Exit Function
End Select
If (RT.Value <= Limit) Then
RTTAIL = "RT Not Met"
ElseIf (RT.Value < 1.5 * Limit) Then
RTTAIL = "RT Not Met"
Else
RTTAIL = "Not a Tail"
End If
End Function



Paul