Ask Your Question

Help with sort macro button [closed]

asked 2014-01-14 17:23:43 +0200

fldynamatic gravatar image


I am very close to switching several of our users from Office 2003 to LO. I am struggling with one excel file. Bascially it has 3 Macro push buttons that don't work one of which is a sort. I need to sort out A5 to AC49 by Column C and create a push button for this. I don't have the time to learn the Macro language.

Could some one please help me? Thanks Francis

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-18 14:12:17.784408


I am not a macro expert but feel that if you provide a bit more information on what kind of data you want to sort in which way someone might be able to help you. It further would be helpful if you provide information on the functionality of the macros; maybe you can post the MS Excel macros.

ROSt52 gravatar imageROSt52 ( 2014-01-15 02:02:18 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2014-01-15 04:15:42 +0200

LDC3 gravatar image

I've recorded this macro that will sort the cells you specified A5:AC49 using the 3rd column:

sub Main
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("")

rem ----------------------------------------------------------------------
dim args1(0) as new
args1(0).Name = "ToPoint"
args1(0).Value = "$A$5:$AC$49"

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

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

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

end sub

If you change args2(7).Value to false, you get a descending sort.

edit flag offensive delete link more


great - this works well - Thank you so much!!

fldynamatic gravatar imagefldynamatic ( 2014-01-15 13:07:23 +0200 )edit

Question Tools

1 follower


Asked: 2014-01-14 17:23:43 +0200

Seen: 2,773 times

Last updated: Jan 15 '14