Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
GUS GUS is offline
external usenet poster
 
Posts: 45
Default automatic sort

I want a macro to automaticly read used columns and then sort the range
with column 1
For example if i have data like this
a b c d
1 gus italy 22 april
2 jim spain 34 may
3 david france 45 june


i don't want to give the range for sort at vba by myself.
I want code to automaticaly define the used range and then sort with the
next code

Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default automatic sort

Gus,

You can use CurrentRegion for your sort range.
Based on what you describe, it may just do the trick.
Check VBA Help for CurrentRegion to be sure.

Anyway.....
Range("A1").CurrentRegion.Sort Key1:=Range("B1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

John

GUS wrote:

I want a macro to automaticly read used columns and then sort the range
with column 1
For example if i have data like this
a b c d
1 gus italy 22 april
2 jim spain 34 may
3 david france 45 june

i don't want to give the range for sort at vba by myself.
I want code to automaticaly define the used range and then sort with the
next code

Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


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
Automatic sort ALEX Excel Discussion (Misc queries) 0 July 27th 06 07:55 PM
Automatic Sort ferg Excel Discussion (Misc queries) 2 July 20th 06 01:33 PM
Automatic League Sort Blade2304 Excel Worksheet Functions 4 May 18th 06 02:37 PM
Automatic Sort Blade2304 Excel Discussion (Misc queries) 1 May 18th 06 10:15 AM
automatic sort Robert Excel Worksheet Functions 6 June 28th 05 02:28 PM


All times are GMT +1. The time now is 10:30 AM.

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"