NewUser Guest
|
Posted: Wed Apr 30, 2003 8:40 am Post subject: Last Cell Macro |
|
|
I have been using the folllowing macro in Excel and would like to apapt it to OpenOffice:
Public Function LastCell(ws As String) As Range
'http://www.beyondtechnology.com/geeks012.shtml
Dim LastRow&, LastCol%
' Error-handling is here in case there is not any
' data in the worksheet
On Error Resume Next
With Sheets(ws)
' Find the last real row
LastRow& = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
' Find the last real column
LastCol% = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
End With
' Finally, initialize a Range object variable for
' the last populated row.
Set LastCell = Sheets(ws).Cells(LastRow&, LastCol%)
End Function
I copied this macro from: http://www.beyondtechnology.com/geeks012.shtml
The problem I'm having is with the .Cells.Find command which gives a
"Object not accessible.. Invalid Object Reference" error.
Can someone tell me what I have to do to get this macro going. Thanks |
|