View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Adam Adam is offline
external usenet poster
 
Posts: 287
Default Simple Do... Until problem

Thanks to both - much appreciated

"Joel" wrote:

RowCount = 16
Do while Range("AU" & RowCount) < ""
Range("AU" & RowCount & ":AV" & (RowCount + 6)).Sort _
Key1:=Range("AV" & RowCount), _
Order1:=xlDescending,
Header:=xlno
RowCount = RowCount + 8
loop


"Adam" wrote:

Hopefully an easy one for someone

I would like to simplify this macro as is needs to go on for quite a few
more repetitions. I'm hoping your able to spot the pattern. Short tables of
2x7 underneath each other, seperated by a line, that need to be sorted into
order of the highest number in column AV first.

I know it's a Do...Until or a For...Next, but i'm still a little
inexperienced in these areas

Range("AU16:AV22").Select
Range("AV16").Activate
Selection.Sort Key1:=Range("AV16"), Order1:=xlDescending,
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("AU24:AV30").Select
Range("AV24").Activate
Selection.Sort Key1:=Range("AV24"), Order1:=xlDescending,
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("AU32:AV38").Select
Range("AV32").Activate
Selection.Sort Key1:=Range("AV32"), Order1:=xlDescending,
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("AU40:AV46").Select
Range("AV40").Activate
Selection.Sort Key1:=Range("AV40"), Order1:=xlDescending,
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal