Criteria range for use by Advanced Filtering are defined in Sheet2 I1-J2.
I use Data-Filter-Advanced Filtering to copy the filtered results from Sheet2 C1-D8 into Sheet3 A1. This works well when done manually by myself while recording the macro.
However, when I run the macro, nothing happens - the filter results are not copied over to Sheet3 A1.
I have taken a look at the recorded macro, and there is no mention here of the cells which contain the criteria range (Sheet2 I1-J2) or the cell to which the results should be copied, Sheet3 A1.
Please see below code from the recorded macro, there must be something missing in the code. I'm stuck...
Code: Select all
sub forum
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 = "$C$1:$D$8"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterSpecialFilter", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FilterExecute", "", 0, Array())
end sub