How to use autofilter on multiple items in excel via Powershell

This topic contains 4 replies, has 3 voices, and was last updated by  Manish Kumar 3 years, 9 months ago.

  • Author
  • #18244

    Jeff Wilson

    Hello, i have a scrip that is data mining in Excel. I need to filter a column based on multiple data, sometimes, two, or maybe more data. i have tried many different methods and i either get only the last value in the array. or an error – {Exception calling "Autofilter" with "3" arguments(s): "Autofilter method of Range class failed". Please help. I have found nothing on the Thanks , Jeff W. 

    Jeffrey I Wilson
    [#filter for column
    $FL = @("lastname, first","lastnamedif, firstnamedif")
    $ | Out-Null

  • #18246

    Tim Pringle

    The autofilter method can take up to five parameters. Have you tried using $null for the parameters that you are not using, so you are always passing five parameters into the method?


    Filter the first column of the select range so that it only lists items which a value of 'FilterMe'

    $excel.Selection.AutoFilter(1, 'FilterMe', 1, $null, $null)

  • #18310

    Jeff Wilson

    Ok, but how can i choose two items, such as "filter me" and job,bob from the same column???
    Thanks in advance.
    Jeff W.

  • #97819

    Manish Kumar

    Use advance filter using criteria range and filter type

You must be logged in to reply to this topic.