#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort data

If I record a macro using the macro recorder. Then I get this
recording.

Sub Makro1()
Range("A1").Select
Range("A1:Q965").Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub

Since my datasheet continues to get larger, I need the
Range("A1:......) to get larger as well.. How do I set it up to check
for the entire datasheet, so that I make sure that the entire sheet is
sorted in the progress???


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Sort data

Rune_Daub < wrote:
If I record a macro using the macro recorder. Then I get this
recording.

Sub Makro1()
Range("A1").Select
Range("A1:Q965").Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub

Since my datasheet continues to get larger, I need the
Range("A1:......) to get larger as well.. How do I set it up to check
for the entire datasheet, so that I make sure that the entire sheet is
sorted in the progress???


You can use the UsedRange property:

Sub Makro1()
ActiveSheet.UsedRange.Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub

Be careful though, because UsedRange takes into account all the cells
that has been formatted, even if there is no data in them.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Sort data

one way:

If your data is contiguous (No completely empty rows or columns) you can
let XL figure it out:

Sub Makro1()
Range("A1").Sort _
Key1:=Range("A1"), _
Order1:=xlAscending, _
Key2:=Range("L2"), _
Order2:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub

Another way, if there is a value in column 1 for all filled rows:

Range("A1:Q" & Range("A" & Rows.Count).End(xlUp).Row).Sort _
Key1:=Range("A1"), _
Order1:=xlAscending, _
Key2:=Range("L2"), _
Order2:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom


In article ,
Rune_Daub wrote:

If I record a macro using the macro recorder. Then I get this
recording.

Sub Makro1()
Range("A1").Select
Range("A1:Q965").Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub

Since my datasheet continues to get larger, I need the
Range("A1:......) to get larger as well.. How do I set it up to check
for the entire datasheet, so that I make sure that the entire sheet is
sorted in the progress???


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Sort data

Hi,
Try,

Sub Makro1()
Range("A1").Select
Range("A1").currentregion.Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
(Excel Add-ins)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort data

My excel sheet consists of 15 columns with headings.
I have 500 rows of information. Not all fields are filled out.
I have formatted 2000 rows to show if an error has occured in th
entered data.

So I cant use the first response by Beto allthough it was a good one
thx...
I cant use the second one by JE McGimpsey cause I cant guarentie tha
all rows and collumns at this point contain information. It will in th
long run.. but not for the next few months.
Shailesh Shah.. wont the currentregion just sort the data until th
first empty cell is encountered in column A???

I know how many columns there are in the sheet... A to Q
Cant we somehow test the last row that has information entered, an
then enter those information into the Range("A1:Q965").?????

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Sort data

Rune_Daub < wrote:

My excel sheet consists of 15 columns with headings.
I have 500 rows of information. Not all fields are filled out.
I have formatted 2000 rows to show if an error has occured in the
entered data.
Shailesh Shah.. wont the currentregion just sort the data until the
first empty cell is encountered in column A???


No, I think CurrentRegion will do. If it don't then I still don't
understand the layout. CurrentRegion will stop when it finds a whole
empty row.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.

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
sort source data sheet while destination shows same data Inobugs Excel Worksheet Functions 1 April 18th 09 09:36 PM
data, sort option is grayed. how to sort on a column? Steve Richter Excel Discussion (Misc queries) 1 September 25th 07 03:25 PM
I want to convert word column data to excel row data to sort addre craywill Excel Discussion (Misc queries) 0 April 18th 06 07:16 PM
data sort is not including all columns in sort Tracy Excel Discussion (Misc queries) 1 October 4th 05 12:16 AM
How do I sort a column of data and have each data row sort accordi Oedalis Excel Discussion (Misc queries) 1 March 17th 05 11:52 PM


All times are GMT +1. The time now is 12:38 PM.

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

About Us

"It's about Microsoft Excel"