How to use autofilter on multiple items in excel via Powershell

Welcome Forums General PowerShell Q&A How to use autofilter on multiple items in excel via Powershell

Viewing 3 reply threads
  • Author
    Posts
    • #18244
      Participant
      Topics: 3
      Replies: 2
      Points: 0
      Rank: Member

      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”)
      $rng=$Worksheet.cells.item(2,38).entirecolumn
      $rng.select | Out-Null
      $excel.Selection.AutoFilter]

    • #18246
      Participant
      Topics: 4
      Replies: 262
      Points: 61
      Rank: Member

      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?

      e.g.

      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
      Participant
      Topics: 3
      Replies: 2
      Points: 0
      Rank: Member

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

      • #97818
        Participant
        Topics: 0
        Replies: 2
        Points: 0
        Rank: Member

        In that case use advance filter

    • #97819
      Participant
      Topics: 0
      Replies: 2
      Points: 0
      Rank: Member

      Use advance filter using criteria range and filter type

Viewing 3 reply threads
  • The topic ‘How to use autofilter on multiple items in excel via Powershell’ is closed to new replies.

One thought on “How to use autofilter on multiple items in excel via Powershell

  1. Pingback: Writing to Excel | Powershell Administrator Blog

Comments are closed.