Sort from row 4 down

D

Desert Piranha

Hi all,

Why won't this sort the range below row 3, or in other words,
the first 3 rows have data, so the sort will start in row 4 and go
down.

Columns("A:J").Select
Selection.Sort _
Key1:=Range("A4"), Order1:=xlAscending, _
Key2:=Range("C4"), Order2:=xlAscending, _
Key3:=Range("B4"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

I thought setting the range would start at row 4 but guess not.
 
N

Norman Jones

Hi Desert Piranha,

Try :

'=============>>
Public Sub Tester()
Dim rng As Range

Set rng = Intersect(Columns("A:J"), ActiveSheet.UsedRange)

Set rng = rng.Offset(3). _
Resize(rng.Rows.Count - 3, rng.Columns.Count)

rng.Sort _
Key1:=Range("A4"), Order1:=xlAscending, _
Key2:=Range("C4"), Order2:=xlAscending, _
Key3:=Range("B4"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

End Sub
'<<=============


---
Regards,
Norman



"Desert Piranha"
 
D

Desert Piranha

Norman said:
Hi Desert Piranha,

Try :

'=============>>
Public Sub Tester()
Dim rng As Range

Set rng = Intersect(Columns("A:J"), ActiveSheet.UsedRange)

Set rng = rng.Offset(3). _
Resize(rng.Rows.Count - 3, rng.Columns.Count)

rng.Sort _
Key1:=Range("A4"), Order1:=xlAscending, _
Key2:=Range("C4"), Order2:=xlAscending, _
Key3:=Range("B4"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

End Sub
'<<=============


---
Regards,
Norman



"Desert Piranha"
message

Thx much, works fine, now to try to finish this project before
daylight.

Thx again Norman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top