Hi,
I have two columns in Calc with 11 rows including header. It’s used as a reimbursement form for expenses.
Colums are Amount and Category. I want it to automatically sum up each category. This is easily done creating to new columns, one with categories without duplicates created using standard filter (I have created a range for Category not including header and using it in filter), and one with sumif.
But when I try do to this in a macro I cannot get it to work. I realize I must do something wrong, but I cannot figure out what. I have done some reading on google searches and in this forum, but I’m hoping this post will help.
Looking av the BASIC code created I observe that StandardFilter is not executed, because it’s commented out. I don’t understand what I’m doing wrong.
Code is looking like this:
REM ***** BASIC *****
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 ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterStandardFilter", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$B$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$B$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterStandardFilter", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FilterExecute", "", 0, Array())
end sub
As I’m a screenshot junkie I would prefer to add screenshots, but I don’t have enough points in the forum yet.
Appreciate the help of the community. Thanks.
Regards, Bjørn