Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel sort method

Status
Not open for further replies.

rcarr

Programmer
Oct 19, 2000
12
0
0
CA
When creating an Excel worksheet from Outlook, the form fails with the error "Expected Statement" on the oSheet.Selection.Sort line. If I make the selection visible, the correct range is selected. Here is the code. Any idea what is causing this?

Set oExcel = Item.Application.CreateObject _
("Excel.Application")
oExcel.Workbooks.Add
Set oSheet = oExcel.Workbooks(1).Worksheets("Sheet1")
' Export data code goes here to fill i rows, 6 cols.
Set varRange = oSheet.Range(oExcel.Cells(6, 1), _
oExcel.Cells(i, 6))
varRange.Select
oSheet.Selection.Sort Key1:=Range("A6"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Randy Carr
randy.carr@carteretcraven.ncemcs.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top