Thread
:
Sorting multiple range using a macro
View Single Post
#
5
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Sorting multiple range using a macro
On the toolbar just touch your reset button (blue square on mine) or
Runreset
then
Sub sortfromloop()
For Each c In Range("A651:A670")
'MsgBox c
x = Left(c, InStr(c, ":") - 1)
'MsgBox x
'Range("C1:D20").Sort Key1:=Range("C1"), Order1:=xlAscending
Range(c).Sort Key1:=Range(x), Order1:=xlAscending
Next c
End Sub
--
Don Guillett
SalesAid Software
"onlinepredator " wrote in
message ...
Hi Kiza,
I already have lots of space in each of the ranges. I mean not all
range have contents in all their cells hence I am not sure as how to
change your code suggestion to suit my needs...... the problem is that
i am not all that good with
VB
.....
Thanks for you
suggestions.
Hi Don Guillett,
I tried to copy your code into the macro and i am getting an error
statement "Can't execute code in break mode"
heres the code
Range("A651:A670").Select
For Each c In Selection
'MsgBox c
x = Left(c, InStr(c, ":") - 1)
'MsgBox x
'Range("C1:D20").Sort Key1:=Range("C1"), Order1:=xlAscending
Range(c).Sort Key1:=Range(x), Order1:=xlAscending
Next c
A651:A670 is where i have stored all the ranges that need to be
sorted... that is A651 = C1:D20 -- A652 = C21:D40 etc
For now i am individualy sorting each range in the code......But would
like to make the code short my looping
Dhanush
---
Message posted from
http://www.ExcelForum.com/
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]