View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Inserting a function

Darin ,

Had to make a couple of changes to make it work for me, but you use with a
simple =fzLastValue(A1:B10) in a worksheet

Function fzLastValue(RangeId As Variant, Optional byColumn As Boolean =
True)
Dim cLast As Long
Dim oLast As Range

Application.Volatile

If byColumn Then
cLast = Cells(Rows.Count, RangeId.Column).End(xlUp).Row
Set oLast = Cells(cLast, RangeId.Column)
Else
cLast = Cells(RangeId.Row, Columns.Count).End(xlToLeft).Column
Set oLast = Cells(RangeId.Row, cLast)
End If

fzLastValue = oLast.Value

End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Darin Kramer" wrote in message
...


Howdie,

I want to insert the function below into VBA.

I create a new module and paste it in, but how do I run it, or see the
results of it?

Thanks

Darin


Function fzLastValue(RangeId As Variant, Optional byColumn As Boolean =
True)
Dim cLast As Long
Dim oLast As Range

Application.Volatile

If byColumn Then
cLast = Cells(Rows.Count, RangeId).End(xlUp).Row
Set oLast = Range(RangeId & cLast)
Else
cLast = Cells(RangeId, Columns.Count).End(xlToLeft).Column
Set oLast = Cells(RangeId, cLast)
End If

fzLastValue = oLast.Value

End Function


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!