aneez has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm trying to filter out unique records in a single coloumn and copy it to another location using the AdvancedFilter function. But everytime I run the code I'm getting the error "Unable to get AdvancedFilter property on the Range Class". Here is the code I have written :

use Win32::OLE::Const 'Microsoft Excel'; $Excel = Win32::OLE->new('Excel.Application'); $book = $Excel->Workbooks->Open("d:\\test.xls"); $sheetdata = $book->Worksheets(1); $sheetdata->{Name} = "Data"; $book->Names->Add({Name=>'abc', RefersTo=>'=Data!$D$1:$D$19'}); $book->Names->Add({Name=>'def', RefersTo=>'=Data!$E$1:$E$19'}); $sheetdata->Range('abc')->AdvancedFilter({Action => 0, CopyToRange=> $ +sheetdata->Range('def'), Unique => 1}); $sheetdata->Activate;

In the above code, the named range 'abc' is the coloumn on which Filtering should be done and the named range 'def' is the coloumn where the unique records should be copied to.

Any help on this regard is hugely aprreciated.

Thanks

Replies are listed 'Best First'.
Re: Using Advanced Filter in Win32::OLE
by Anonymous Monk on Jul 25, 2012 at 12:35 UTC

      Thanks a lot for the tip. It worked.