Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Sam
 
Posts: n/a
Default sorting out columns but only for some rows

Hi,

I would like to create a macros that will sort out the first 5 rows of
my spreadsheet only. The reason for that is that in the middle of my
spreadsheet i have another group of cells that represent a table and I
don't want that one to be sorted.

How can i do that ?

Thx

  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Sam,

Either select just the cells that you want sorted, prior to the sort, or
insert a new row between the tables to prevent them being sorted together.

HTH,
Bernie
MS Excel MVP


"Sam" wrote in message
oups.com...
Hi,

I would like to create a macros that will sort out the first 5 rows of
my spreadsheet only. The reason for that is that in the middle of my
spreadsheet i have another group of cells that represent a table and I
don't want that one to be sorted.

How can i do that ?

Thx



  #3   Report Post  
JulieD
 
Posts: n/a
Default

Hi Sam

something along these lines

sub sortsome()

Rows("1:5").Sort Key1:=Range("a2"), Order1:=xlAscending, Header:=xlYes,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

End sub

where you have a header row (if not, change Header:=xlYes to Header:=xlNo
and A2 to A1) and you want to sort on the value in column A, if not, change
the A to whatever column you want to sort on

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Sam" wrote in message
oups.com...
Hi,

I would like to create a macros that will sort out the first 5 rows of
my spreadsheet only. The reason for that is that in the middle of my
spreadsheet i have another group of cells that represent a table and I
don't want that one to be sorted.

How can i do that ?

Thx



  #4   Report Post  
JulieD
 
Posts: n/a
Default

oops the _ was supposed to be on the same lines as the xlYes,

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"JulieD" wrote in message
...
Hi Sam

something along these lines

sub sortsome()

Rows("1:5").Sort Key1:=Range("a2"), Order1:=xlAscending, Header:=xlYes,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

End sub

where you have a header row (if not, change Header:=xlYes to Header:=xlNo
and A2 to A1) and you want to sort on the value in column A, if not,
change the A to whatever column you want to sort on

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
...well i'm working on it anyway
"Sam" wrote in message
oups.com...
Hi,

I would like to create a macros that will sort out the first 5 rows of
my spreadsheet only. The reason for that is that in the middle of my
spreadsheet i have another group of cells that represent a table and I
don't want that one to be sorted.

How can i do that ?

Thx





  #5   Report Post  
Sam
 
Posts: n/a
Default

i've done that. but it still modifies the rows below.
You can find my spreadsheet he
http://graphicsxp.no-ip.com/share/Book1.xls
maybe I haven't been clear enough about what i want to achieve and
you'll get the visual straight away.

Thx



  #6   Report Post  
Max
 
Posts: n/a
Default

The recorded macro below seems to be able to do the job ..
(Sort by col C - Descending, then by col B - ascending)

Sub Macro2()
Sheets("Sheet1").Select
Rows("1:6").Select
Selection.sort Key1:=Range("C2"), Order1:=xlDescending,
Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom
Range("A1").Select
End Sub

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Sam" wrote in message
oups.com...
i've done that. but it still modifies the rows below.
You can find my spreadsheet he
http://graphicsxp.no-ip.com/share/Book1.xls
maybe I haven't been clear enough about what i want to achieve and
you'll get the visual straight away.

Thx



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hidden rows & columns slow file open Simon Shaw Excel Discussion (Misc queries) 0 April 5th 05 12:21 AM
Removing Near-Duplicate Rows, Leaving Those w/Most Data in Specific Columns foofoo Excel Discussion (Misc queries) 1 April 2nd 05 12:02 AM
How to keep rows together when sorting columns? Amit Excel Worksheet Functions 1 March 28th 05 06:01 PM
Sorting rows AND columns 3D Excel Worksheet Functions 2 January 7th 05 02:15 AM
interchange columns with rows Herman Excel Discussion (Misc queries) 2 December 8th 04 05:40 PM


All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"