Help with sort macro button

Hi,

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

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.

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("com.sun.star.frame.DispatchHelper")

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

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

rem ----------------------------------------------------------------------
dim args2(7) as new com.sun.star.beans.PropertyValue
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.

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