About

This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.

Advertisements

3 thoughts on “About

  1. I have been trying to utilize your logic to sort an excel sheet by column A in ascending order, while ignoring the top row (which I use for labels), but cannot get this to work. It sorts the header row (called Servers) along with all the other rows. I want the first row left alone and no matter what i’ve tried (just about every example i can find online) nothing works. Do you have any suggestions?

    Your line:
    $r2 = $ws.Range(“B2”) # Sorts on Column B and leaves Header alone

    My script:
    $Excel = new-object -comobject excel.application
    $Excel.Visible = $True
    $Excel.DisplayAlerts = $True
    $Workbook = $Excel.Workbooks.Open(“C:\Scripts\Powershell\Servers.xls”)
    $Sheet = $workbook.Worksheets.Item(2)
    $UsdRange = $Sheet.UsedRange
    $SelRange = $Sheet.Range(“A2”)
    $UsdRange.Sort($SelRange,1)

    • Try this:

      Your script:
      $Excel = new-object -comobject excel.application
      $Excel.Visible = $True
      $Excel.DisplayAlerts = $True
      $Workbook = $Excel.Workbooks.Open(“C:\Scripts\Powershell\Servers.xls”)
      $Sheet = $workbook.Worksheets.Item(2)
      $UsdRange = $EXCEL.Range(“A2:E150”) #<– You need to exclude the first row from the $UsdRange.
      $SelRange = $Sheet.Range("A2")
      $UsdRange.Sort($SelRange,1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s