Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 881
Hatsune Yuki Avatar asked Nov 19 '25 17:11

Hatsune Yuki


1 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)
like image 158
Ansgar Wiechers Avatar answered Nov 21 '25 10:11

Ansgar Wiechers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!