View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sheeloo[_2_] Sheeloo[_2_] is offline
external usenet poster
 
Posts: 364
Default How to sort a selection of rows?

Use something like
Selection.Sort Key1:=Range("A1"), Order1:=xlDescending, Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal

"jgmiddel" wrote:

This code selects some rows in my sheet:

With Rng.Parent
.Select
.Range("B4", LastCell).Select
End With

The number of columns and rows are variable. I want to sort the rows.
How can I do it? I am working in Excel 2007.

Any help is welcome!!