'PowerShell script to copy filtered data in Excel to another sheet
I am new to PowerShell. I have a file name as Input.xlsx file, which will contain 3 columns and we an filter on any column and save it.
My requirement is to copy the filtered data in another sheet using PowerShell.
I wrote this using VBA and it's working, but I need to do same thing using PowerShell.
Option Explicit
Sub Importe()
Dim lastRow As Long
lastRow = Worksheets("Sheet1").Cells(1, 1).SpecialCells(xlCellTypeVisible).End(xlDown).Row
Worksheets.Add
With ActiveSheet
ActiveWorkbook.Worksheets("Sheet1").Range("A1:A" & lastRow).SpecialCells(xlCellTypeVisible).Copy
.Range("A1").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets("Sheet1").Range("B1:B" & lastRow).SpecialCells(xlCellTypeVisible).Copy
.Range("B1").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets("Sheet1").Range("C1:C" & lastRow).SpecialCells(xlCellTypeVisible).Copy
.Range("C1").PasteSpecial xlPasteValues
End With
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|