View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Unger Dave Unger is offline
external usenet poster
 
Posts: 153
Default Sorting question-is this possible

Hi Jouioui,

This might be one way to do it. I've done limited testing, but it
seems to work Ok.

Just add your updated rows at the bottom of the list then run this
macro.

Sub SrtCat()

Dim rng As Range, x As Integer

Set rng = ActiveSheet.UsedRange

rng.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("D1")
_
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom

Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))

For x = rng.Count To 3 Step -1
'rng(x).Select
If rng(x) < rng(x - 1) Then rng(x).EntireRow.Insert
(xlShiftDown)
Next x
End Sub

regards,

DaveU


On Mar 6, 9:36 am, JOUIOUI wrote:
I would like to write code sorting the entire spreadsheet, excluding headers,
by first sorting column I to put all topics together in descending order and
then adding an empty row at the end of each topic to separate them. My
topics are just 3 values and they are

Stationary
Posters
Books

Then my next sort is to isolate each topic and sort each topic individually
by column D ascending. Col D is a currency value.

The end result would be each topic in column I would be sorted by ascending
dollar value in Col D

This spreadsheet is updated each day so the row count is unknown. Is this
even possible?