View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Angela[_2_] Angela[_2_] is offline
external usenet poster
 
Posts: 38
Default UDF for Aging in excel - Help needed

Hi Joeu,

Many thanks for your reply.

:) ya that was as apostrophe :P

I have checked both your codes with variations but I'm unable to
satisfy a list of senarios with any one of them at the moment.

We are very close.
I have tested 25 senarios and would like to share with you.
I'm so far successful with 24. Only stuck with 1.
Please let me know how to share my findings in an excel sheet with
you.
I would like to share a table with all 25 senarios that I'm looking
into.

Here is the code that I am working on.. This works with 24 cases and
is only left with 1.
------------------------------------
Function AgeBucket(TargetDate) As String

Dim AgeLmt As Variant
Dim AgeRng As Variant

TargetDateG = Format(TargetDate, "Short Date")

AgeLmt = Array(0, 7.51, 14.51, 21.51, 30.51, 45.51, 60.51)
AgeRng = Array("0-7", "8-14", "15-21", "22-30", "31-45", "46-60",
"60")

If TargetDate = TargetDateG Or TargetDate < 1 Then
AgeBucket = "Invalid date or out of range"
Else

If CDate(TargetDate) Date Then
AgeBucket = "Date is greater than current date."
Else

If CDate(TargetDate) <= Date Then
AgeBucket = WorksheetFunction.Lookup(Date - CDate(TargetDate), AgeLmt,
AgeRng)
End If
End If
End If
End Function
-------------------------------------------------------

Many thanks for your patience and help.