Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

sorting data

ResolvedVersion 2007

Mimi has attended:
Excel VBA Intro Intermediate course

Sorting data

Hi,

I am trying to sort some data within my worksheet.

There are headings in rows 1, columns A to J.
I would like to sort data in ascending order for (in ascending order): column C then
column D.

My code is below:
Selection.CurrentRegion.Select
Selection.sort key3:=Range("c1"), order3:=xlAscending, key4:=Range("d1"), order4:=xlAscending, Header:=xlGuess, ordercustom:=1

When I run this I get an error: run time error '1004'.
"Application-defined or object-defined run time error"

Thanks for any advice!

Mimi

RE: sorting data

Hi Mimi

Thanks for your question

If you replace Key 3 and 4 with key 1 and 2 then it seems to work fine. You can only sort by up to three keys. You also need to rename 0rder 3 and 4 order 1 and 2 as well

Regards

Stephen

Mon 26 Jul 2010: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Change the Print button so it brings up the Print dialogue box

If you want to bring up the Print dialogue box to check your print settings when you hit the Print button, do the following:

1. Right-click on the toolbar that displays the Print button.

2. Select Customise.

3. Click on the Print button on the toolbar to select it, then hold the left mouse button down and drag the button towards the screen below. The button should come off the toolbar.

4. In the Customise dialogue box on your screen, select the Commands tab.

5. Select File from the Categories list, and then locate the Print... icon (looks like the normal Print button, but the word Print has three dots following it).

6. Click on the Print... icon to select it, then use your left mouse to drag and drop the icon onto the toolbar at the top of the screen.

7. Close the Customise dialogue box.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.