Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 19th, 2005, 12:33 AM
Authorized User
Points: 172, Level: 3
Points: 172, Level: 3 Points: 172, Level: 3 Points: 172, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: Singapore, , Singapore.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sorting

Hi,

I recorded the macro to sort some data in Excel and copied the code into my program. But after doing so, the macro won't work. What could be wrong?

Worksheets("Data").Select
Worksheets("Data").Columns("A:L").Select
Worksheets("Data").Range("L1").Select
Selection.Sort Key1:=Range("L1"), Order1:=xlAscending, Key2:=Range("G1") _
            , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
            , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
            xlSortNormal

The error message is "Run-time error '1004': Application-defined or object-defined error.

Pls advise.
Thanks in advance.

Reply With Quote
  #2 (permalink)  
Old September 19th, 2005, 05:03 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The code works fine.

Try to debug your code and find out where the error occurs.
Set break point in the first row.
Run the code.
After stopping to break point press F8 to run code row by row.

-vemaju

ps. you can remove these lines
Worksheets("Data").Columns("A:L").Select
Worksheets("Data").Range("L1").Select



Reply With Quote
  #3 (permalink)  
Old September 19th, 2005, 09:31 PM
Authorized User
Points: 172, Level: 3
Points: 172, Level: 3 Points: 172, Level: 3 Points: 172, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: Singapore, , Singapore.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The run-time error happens at the following code:

Selection.Sort Key1:=Range("L1"), Order1:=xlAscending, Key2:=Range("G1") _
            , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
            , Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
            xlSortNormal

What other possible errors could there be?

Please advise. Thanks in advance.

Regards

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting member XSLT 25 July 13th, 2007 08:44 AM
SORTING pallone XSLT 3 October 29th, 2006 08:45 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
Sorting? pbernardo XSLT 2 October 27th, 2003 11:34 AM
Need help Sorting athanatos XSLT 5 August 11th, 2003 07:51 PM



All times are GMT -4. The time now is 10:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.