Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sorting Excel Spreadsheet ??

Posted on 2006-06-16
4
Medium Priority
?
217 Views
Last Modified: 2010-04-30
I have Excel worksheets.
I want to write a code to sort it.
But because I have first three rows as headers.
I need to use 4th row and on to sort it.
Say there are 20 rows so I need to sort from 4th to 20th rows.
Because users will add more rows I won't know the last row numbers.

I want to find out if I can code to sort from 4th row to whatever row I have.
How can I do that if this can be done easily??
Thanks much.

0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 800 total points
ID: 16921453
how about

ActiveSheet.Range("C5:C" & ActiveSheet.Range("C1").SpecialCells(xlCellTypeLastCell).Row).Sort _
    Key1:=Range("C5"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 1200 total points
ID: 16928058
Assuming column A is the column to sort upon, and the data will be sorted in ascending alphabetical order:

ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Rows.Count - 3).Offset(3).Sort Key1:=[A4], Order1:=xlAscending

If you wish to sort on, say, column A ascending, then column B descending, then column E ascending...

ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Rows.Count - 3).Offset(3).Sort Key1:=[A4], Order1:=xlAscending, Key2:=[B4], Order2:=xlDescending, Key3:=[E4], Order3:=xlAscending


BFN,

fp.
0
 

Author Comment

by:dkim18
ID: 16942914
Thank so much guys.

0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16942925
You're very welcome.

Thanks for closing the question.

BFN,

fp.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question