none
Powershell script to apply filter on column "D" and delete the filtered rows RRS feed

  • Question

  • Hi

     my Excel is having column "D1" with header row and I Want to filter with text "abc" and delete the rows after filtered using powershell script 

    $worksheet.usedrange.autofilter(4,"*abc*",1)

    $worksheet.usedrange.specialcells(12).Entirerow.Delete()

    1) Problem : header row also gets deleted ?

    2) Problem  : autofilter 1st parameter can be used as "D1" instead of 4 ?

    

    

    Friday, September 7, 2018 6:50 AM

Answers

  • 

       For 1 question , #worksheet.usedrange.offset(1,0).specialcells(12).Entirerow.Delete() worked for me.

    • Marked as answer by Fabcoder Friday, September 21, 2018 5:51 AM
    Friday, September 21, 2018 5:51 AM

All replies

  • Hi Fabocoder,

    For your first question.

                You can check first return value's row value, and than start delete unnecessary rows.

    For your second question.

                It could only be int. Due to first value will select specific column. 


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, September 11, 2018 8:23 AM
    Moderator
  • Hi Fabocoder

    Any update?


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, September 17, 2018 4:44 AM
    Moderator
  • 

       For 1 question , #worksheet.usedrange.offset(1,0).specialcells(12).Entirerow.Delete() worked for me.

    • Marked as answer by Fabcoder Friday, September 21, 2018 5:51 AM
    Friday, September 21, 2018 5:51 AM