Hi Ron,
UDF is working Great!
Found my problem: cell returning empty text.
Thank you so much for your assistance.
Cheers,
Sam
Sam wrote:
Hi Ron,
Thank you for providing this neat Function. Unfortunately, it is returning
#Value Error; any ideas?
To use this, enter a formula of the type:
=label(A1:B30,D1)
where A1:B30 is your table of Numerical Labels and Data, and D1 is the Sum Target.
===========================================
Option Explicit
Function Label(ByVal DataTable As Range, SumTargetValue As Range)
Dim Dt As Variant
Dim i As Long
Dim s As Double
Dt = DataTable
For i = UBound(Dt) To 1 Step -1
s = s + Dt(i, 2)
If s = SumTargetValue Then Exit For
If i = 1 Then
Label = CVErr(xlErrNum)
Exit Function
End If
Next i
Do Until Label < 0
Label = Dt(i, 1)
i = i - 1
Loop
End Function
=============================
--ron
Cheers,
Sam
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200510/1