![]() |
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 |
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 |
All times are GMT +1. The time now is 02:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com