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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to sort data by a certain column

Status
Not open for further replies.

ozzieugene

Programmer
Jun 1, 2003
4
0
0
SG
Does anyone know how to write a macro which will sort the data by a certain column.

Only want to sort certain cells in a worksheet, not the entire worksheet
 
What exactly do you want to sort?

You can use Data > Sort within excel to sort in ascending / Descending order any given range.

Or

You can use the advance filter to sort by using a criteria you define.

Rgds, John

 
Hi
This will sort only the cells in the given range even if that range is in the middle of a larger range

Code:
Range("C1:C20").Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top