Hi I have 17000 rows 20 columns spreadsheet base spreadsheet
I have 30 different iterations of it, it is a mailing list that is then manipulated by if statements, etc to create delivery routes.
I am attempting to speed up the process by using macros and the first one I recorded was an attempt to extract a delivery route mailing list
I started the recorder then highlighted the area to be sorted I then attempted to do the sort via Alt D then Alt S then moved to the correct column by using the down arrow then Atl O
I then used my mouse to stop recording
The sort has been done in the way I require but when I attempt to run the macro again all I get is the high lighting and no sort
I have looked at the code and the last lines do not look right
I can see as I tap across to highlight the top row and the use shift ctrl arrow down to complete the highlighting of the rows to be sorted but it is the last bit that is not right
Here is my code
***start edit: @karolus ***
sub testdata2021
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 = "$B$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ## replaced '…Value = 1' with '…Value = 19'
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 19
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args2())
rem ## and removed 18 identical Blocks like above
dim args21(0) as new com.sun.star.beans.PropertyValue
args21(0).Name = "By"
args21(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfDataSel", "", 0, args21())
***rem ## removed 'rem' in front next line***
dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, Array())
end sub
edit by @karolus : corrected code …does it work this way??
Yes I can see the problem now thank you