ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort from row 4 down (https://www.excelbanter.com/excel-programming/351386-sort-row-4-down.html)

Desert Piranha[_39_]

Sort from row 4 down
 

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.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=504718


Norman Jones

Sort from row 4 down
 
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"
<Desert.Piranha.2262jy_1138152603.1292@excelforu m-nospam.com wrote in
message news:Desert.Piranha.2262jy_1138152603.1292@excelfo rum-nospam.com...

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.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile:
http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=504718




Desert Piranha[_40_]

Sort from row 4 down
 

Norman Jones Wrote:
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"
<Desert.Piranha.2262jy_1138152603.1292@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.2262jy_1138152603.1292@excelfo rum-nospam.com...

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.


--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:
http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=504718
Hi Norman,


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

Thx again Norman


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=504718



All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com