Home » excel » How to Insert Cells (not Entire Row/Column) in Excel using Powershell

How to Insert Cells (not Entire Row/Column) in Excel using Powershell

Posted by: admin April 23, 2020 Leave a comment

Questions:

As the title suggested, I’m not sure how to do the equivalent of selecting only a portion of a row and insert cells (shift rows down) using Powershell. It seems like all tutorials online are about inserting the entire row or entire column which is not what I want to do.

Any ideas?

Thanks.

How to&Answers:

Try something like this:

$xl = New-Object -COM "Excel.Application"
$xl.Visible = $true

$wb = $xl.Workbooks.Open "C:\path\to\your.xlsx"
$ws = $wb.Sheets.Item(1)

$ws.Range("C5:E9").Insert(-4121)