excel sort descending

tell application “Microsoft Excel”
tell sheet “Details” to sort column 5 key1 column 5 order1 sort descending
end tell

This sorts ascending in Excel. Anyone know why or how to fix?

Hi,

the script works perfectly on my machine (G5 PPC, Office 2004, OS 10.4.9)

It works exactly the same whether I put ascending or descending in the script…
I need it to be descending so the newest date goes to the top.
dzelnio

Model: PowerBook G4
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

This works for me as well:

I loaded up an empty sheet with a bunch of dates, and it worked as instructed, regardless of whether or not I told it to ascend or descend.


tell application "Microsoft Excel"
	tell worksheet 1 to sort column 5 key1 column 5 order1 sort descending
end tell

You mentioned in your other thread something about a header, which I have not been able to study about as of yet. Could that be the problem? Perhaps some the fields have date errors? Could you do a copy/paste of some of the field data for us?

CAS,

I want the newest date and time to sort to the top.

Per your request:
Column A: File Name
Column B: Date
Column C: Word Count
Column D: Placed files
Column E: Date2
The two dates are related. The first is considered text by Excel, so I had to write a formula to convert it to become a date in column E.
Column E formula is: =IF(A3=“”,“”,TRIM(REPLACE(B3,1,FIND(“,”,B3),“”))+0)

Thanks again!

dzelnio

AARS June 07 .indd Monday, June 4, 2007 7:39:33 AM 1749 7 06/04/07 07:39:33 AM
AARS June 07 .indd Monday, June 4, 2007 7:39:38 AM 1749 7 06/04/07 07:39:38 AM
MWERG TEMPLATE.indd Monday, June 4, 2007 8:25:18 AM 6193 12 06/04/07 08:25:18 AM
csx mechanical news template.indd Monday, June 4, 2007 8:27:57 AM 5551 28 06/04/07 08:27:57 AM
Zone 8 Template.indd Monday, June 4, 2007 11:59:36 AM 656 0 06/04/07 11:59:36 AM
All Aboard Template.indd Monday, June 4, 2007 2:04:43 PM 863 4 06/04/07 02:04:43 PM
The HDC Dispatch June 2007.indd Tuesday, June 5, 2007 7:54:36 AM 2679 1 06/05/07 07:54:36 AM
The HDC Dispatch June 2007.indd Tuesday, June 5, 2007 8:31:30 AM 2679 1 06/05/07 08:31:30 AM

I solved this project with a macro in Office.
Perhaps this is one of those bugs in Applescript/Excel I read about once in a while.
Thanks for all the advice people!
dzelnio