i want sort out 1 column (it target date , want sort out earliest date). thing first row text (name of column), when sort out column f (target date), text row goes end of excel document. column names stay , on top of every column.
here code:
$objrange = $worksheet.usedrange $objrange2 = $excel.range("f2") [void]$objrange.sort($objrange2.range("f2"))
i not sure how exclude sorting first row.
since range has headers, have add argument sort method indicate should not sort headers.
your range command this:
[void]$objrange.sort($objrange2,1,$null,$null,1,$null,1,1)
the sort method doesn't $null xlsortorder parameters specified 1 means ascending. if need descending, use 2. last 1 parameter care about. specifying 1 means yes, range has headers should not included in sort operation.
syntax reference:
https://msdn.microsoft.com/en-us/library/office/ff840646.aspx
Comments
Post a Comment