OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Last Cell Macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
NewUser
Guest





PostPosted: Wed Apr 30, 2003 8:40 am    Post subject: Last Cell Macro Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group