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 lastcell in thiscolumn function error

Function lastcellref(thiscolumn As Variant)
Dim lastcell As Variant
Set lastcell = Cells(Rows.Count, thiscolumn.Column).End(xlUp)
lastcellref = lastcell.AddressLocal(True, True)
End Function



--

HTH

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


"deano" wrote in message
ups.com...
Cheers all,
I wrote a UFD to return address of last cell of a column of data. The
function takes a cell reference in the column of interest as its
argument.

For example The data is in a range on worksheet1 B2:D6, lastcellref(b2)
should return $b$6

the Function code is:

Function lastcellref(thiscolumn As Variant)
Dim lastcell As Variant
Set lastcell = Cells(1001, thiscolumn.Column).End(xlUp)
Set lastcellref = lastcell.AddressLocal(RowAbsolute:=True,
columnabsolute:=True)
End Function

when I run this function, I get Run time error 424, object required.
what am I doing wrong?