I am trying to use the Excel advanced filter through PowerShell, but I am not having any luck. I can use an autofilter successfully by running the following code:
$rangetofilter = $worksheet2.usedrange.select
$excel.selection.autofilter(2, "TestFilter")
However, I don't understand how to properly convert the syntax given in Range.AdvancedFilter Method to something that PowerShell will accept. For example, I've tried
$excel.selection.AdvancedFilter("xlFilterInPlace", "", "", "TRUE")
But I get the following error:
Exception calling "AdvancedFilter" with "4" argument(s): "AdvancedFilter method of
Range class failed"
At line:1 char:32
+ $excel.selection.AdvancedFilter <<<< ("xlFilterInPlace","","","TRUE")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
So is there a way to run an Excel advanced filter through PowerShell?
I found this: Delete duplicate rows in excel using advanced filter, but it is not working either...