Saving a sort?

Discuss the spreadsheet application
Post Reply
DaveMoorman
Posts: 4
Joined: Wed May 09, 2018 3:14 am

Saving a sort?

Post by DaveMoorman »

In Calc, I often sort by the same three columns, and it would be very handy to be able to save a sort, so I don't have to specify the columns/order for each sort. Is there a way to do this in OO? Thanks.
OpenOffice 4.15 Macintosh OS 10.13.4
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Saving a sort?

Post by RusselB »

Try looking at Tools - Options - OpenOffice Calc - Sort Lists
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
DaveMoorman
Posts: 4
Joined: Wed May 09, 2018 3:14 am

Re: Saving a sort?

Post by DaveMoorman »

There is no "Options" option in my Tools menu.
OpenOffice 4.15 Macintosh OS 10.13.4
FJCC
Moderator
Posts: 9281
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Saving a sort?

Post by FJCC »

I think you can save the sort conditions by highlighting the data cells and then selecting the menu Data -> Define Range. Then do the sort and it will be remembered. To add data to the range, insert rows rather than appending data to rows below the range.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Saving a sort?

Post by Zizi64 »

The AOO and LO can remember the parameters of the last sorting procedure automatically in a ODF type spreadsheet file. But you must select (to sort) precisely same cell range every time when you want to sort that range.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Saving a sort?

Post by Zizi64 »

There is no "Options" option in my Tools menu.
Options (on Windows and Linux) = Preferences (on MAC)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
DaveMoorman
Posts: 4
Joined: Wed May 09, 2018 3:14 am

Re: Saving a sort?

Post by DaveMoorman »

Thanks for the quick replies.

Saving the data range would not work, because every time I sort, it's a different range (in the same spreadsheet). Inserting rows is about as cumbersome as specifying the sort order, because formulas would have to be copied or filled, etc. Excel remembered the sort order, which made it very easy. So far, that's all I miss from Excel.
OpenOffice 4.15 Macintosh OS 10.13.4
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Saving a sort?

Post by Zizi64 »

Try to record or write one or more macro/s/ for this task.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Saving a sort?

Post by Zizi64 »

Here is a recorded macro:

Code: Select all

sub Sort1
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ByRows"
args1(0).Value = true
args1(1).Name = "HasHeader"
args1(1).Value = true
args1(2).Name = "CaseSensitive"
args1(2).Value = false
args1(3).Name = "NaturalSort"
args1(3).Value = false
args1(4).Name = "IncludeAttribs"
args1(4).Value = true
args1(5).Name = "UserDefIndex"
args1(5).Value = 0
args1(6).Name = "Col1"
args1(6).Value = 2
args1(7).Name = "Ascending1"
args1(7).Value = false

dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args1())


end sub
The Macro Recorder was started AFTER selecting the desired range, therefore the macro will run of athe actual selected cell range. (You must select the range manually.)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
DaveMoorman
Posts: 4
Joined: Wed May 09, 2018 3:14 am

Re: Saving a sort?

Post by DaveMoorman »

Thanks, Tibor. Excellent suggestion and I'll try it out.
OpenOffice 4.15 Macintosh OS 10.13.4
Post Reply