LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBScript Automation of Excel Spreadsheet Sorting & Filtering

To the best of my knowledge, it won't work with that construct, because the
arugment to sort isn't a string.

Try this:

xlSelection.Sort xl.Activesheet.Range("A1"),1, _
xl.Activesheet.Range("D1"),,2,,,False,1,True

I left out DataOption1 and DataOption2 because those don't exist before
xl2002.

--
Regards,
Tom Ogilvy

"Steve Munson" wrote in message
...
Tom,

I assumed up front I would need to define the constants
and that didn't do it, so I've now tried placing the
values there, and also tried eliminating the colons, but
to no avail.

In all cases, I've been using a SortString variable to
contain all the details, as there was no other way to
keep the colons in there.

Here's the code snippet:
================================================== ========
==================
SortString = "Key1:=Range(" & Chr(34) & "A1" & Chr(34)
& "), Order1:=1, "
SortString = SortString & "Key2:=Range(" & Chr(34) & "D1"
& Chr(34) & "), "
SortString = SortString & "Order2:=2, Header:=0,
OrderCustom:=1, "
SortString = SortString & "MatchCase:=False,
Orientation:=1, "
SortString = SortString & "DataOption1:=0, DataOption2:=0"
XL.Selection.Sort SortString
================================================== ========
==================
Your thoughts?

Steve
-----Original Message-----
I suspect vbscript does not understand the build in xl

constant definitions.

such as order1:=xlAscending

this would look like order1:=0, but the value of

xlAscending is 1

so the sort is probably being executed, but you are not

seeing any changes.

You need to hard code the values of the constants or

define them in your
code.

This would be true for the autofilter as well.

--
Regards,
Tom Ogilvy

"Stephen Munson" wrote in

message
...
Hello All,

Does anyone know how to code in VBScript the details
surrounding sorting a spreadsheet? I've tried using

the
code you get from recording a macro of doing the sort
manually, and while I don't get syntax erros, I don't

get
any sorting done either. I've tried placing those
details into a string var and then using that as the
parameter, and that fails the same way. I've tried
taking out the ":"'s and maybe I also need to eliminate
the constants too? If anyone has any suggestions,
please let me know, as I have the exact same problem

for
performing an AutoFilter. Thanks!

Steve Munson



.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting data and Advance filtering to get totals on a spreadsheet Pinlaro Excel Discussion (Misc queries) 4 December 19th 08 05:13 PM
Excel Sorting / Filtering Colored Cells Renegade Excel Worksheet Functions 1 October 17th 08 05:32 PM
Excel - filtering, sorting? feliks27 Excel Worksheet Functions 1 April 25th 06 03:34 AM
Can i include a vbscript file with an xml spreadsheet? Neil.Wills Excel Discussion (Misc queries) 0 September 1st 05 12:34 AM
Excel should allow sorting and filtering based on cell color. Linda Excel Worksheet Functions 3 June 20th 05 05:18 PM


All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"