Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Sorting an Excel worksheet with header row in powershell

Avatar of Bill Ehardt
Bill Ehardt asked on
Microsoft ExcelScripting LanguagesVB ScriptPowershell
4 Comments1 Solution10208 ViewsLast Modified:
I'm trying to learn powershell from a vbscript background and for the life of me I can't figure out how to properly sort a worksheet in powershell.

I want to sort descending on column H, but I have a header row, so I'd like to start on cell H2.

How would I do something like this? And how would I sort on 2 separate columns? I can't seem to find any references specifically for powershell on the web.
$excel = New-Object -ComObject excel.application
$excel.visible=$true
$wb = $excel.Workbooks.Open("C:\scripts\worksheet.xls")
$ws = $wb.Worksheets.item(1)
$range=$ws.usedrange
$range.Sort($ws.range("h2"),2)
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
QlemoFlag of Germany image"Batchelor", Developer and EE Topic Advisor
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers