[Solved] LASTROW function
[Solved] LASTROW function
I'm a newbie to OpenOffice. Some of my MS Office files use a LASTROW function that picks a value from the last row with entries on a spreadsheet. Is there a LASTROW function available for OpenOffice?
Last edited by jess66 on Sun Jan 13, 2008 4:50 am, edited 2 times in total.
Re: LASTROW function
Neither Excel nor Calc have a LASTROW function. In both you can write a Custom Basic function to return this for you.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
- kingfisher
- Volunteer
- Posts: 2123
- Joined: Tue Nov 20, 2007 10:53 am
Re: LASTROW function
If you have data arranged by row chronologically with the dates in one column, you could use VLOOKUP in conjunction with MAX or DMAX.
Apache OpenOffice 4.1.9 on Linux
Re: LASTROW function
this one is take from colorRows
Does this help?
[posting from vacation: 8°52'55"N 98°16'1" E; actually 29°C]
Code: Select all
'...
oDoc = ThisComponent
'...
actSheet = oDoc.currentController.ActiveSheet
vLastPos = FUNC_LastUsedCell(actSheet)
lRows = vLastPos(0)
' ...
' and the funtion used
' -------------------------------------------------------------------
' function uses variant array to return more than one value
Function FUNC_LastUsedCell(oSheet as Object) as Variant
oCursor = oSheet.createCursor()
oCursor.gotoEndOfUsedArea(TRUE)
oEndAdr = oCursor.getRangeAddress
Dim vLastUsedCell(1) as Variant
vLastUsedCell(0) = oEndAdr.EndRow
vLastUsedCell(1) = oEndAdr.EndColumn
FUNC_LastUsedCell = vLastUsedCell()
End Function
[posting from vacation: 8°52'55"N 98°16'1" E; actually 29°C]
Re: LASTROW function
Apply a userdefined style to a whole column and the used area reaches to the bottom of the sheet.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: LASTROW function
Since I already have a LASTROW function in XL, (part of a Morefunc add-on), my question should have been: How do I make this add-on accessible to Calc?
Re: LASTROW function
Addons use special "communication channels" to interact with the application they are written for. The code assumes that it is integrated into a particular application to communicate with. It is technically impossible to use add-ons with a third party application.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: LASTROW function
Here's my effort to return the value of some cell in the last row. You must define the value of the col variable.
Code: Select all
sub LastRowContentOfSomeCell
dim document as object,col
col = 0 'Columns are counted from 0 so this is column A.
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Sel"
args1(0).Value = false
dispatcher.executeDispatch(document, ".uno:GoToEndOfData", "", 0, args1())
Dim oCell,oSheet,targetCell
oCell = ThisComponent.CurrentSelection
oSheet = ThisComponent.Sheets.getByIndex(oCell.CellAddress.Sheet)
targetCell = oSheet.getCellByPosition(col,oCell.CellAddress.Row)
MsgBox targetCell.String
end sub
Re: LASTROW function
No, it does not***Villeroy wrote:Apply a userdefined style to a whole column and the used area reaches to the bottom of the sheet.
Apply a user defined formular to a column will do - but that was not the question, was it?
***[tested with OOo 2.1 on Suse 9.3 here - still on holidays with an "old" notebook]
Re: LASTROW function
Sorry, whole column does not hold true, but have a look at the attachment (contains macro, push hyperlink @A1)
- Attachments
-
- UsedRange.ods
- Used range set by formatting only
- (15.11 KiB) Downloaded 736 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: LASTROW function
I've found the VLOOKUP function works for me. The first column is a continuous ascending date with entries almost every day, so the following works even if the date is off a day or two from TODAY.
Thanks for the help
VLOOKUP(TODAY();array;index)
Thanks for the help
VLOOKUP(TODAY();array;index)