View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
kiza[_16_] kiza[_16_] is offline
external usenet poster
 
Posts: 1
Default Sorting multiple range using a macro

Dhanush,

I have looked at your coding and am a little unsure how you are sorting
your ranges as they seem to over lap. I have not changed your coding,
just added to it in order to provide you with the loop function.

Sub Sort()
'
Dim rwIndex, ColIndex
'
rwIndex = 1
ColIndex = 3
'
Do Until Range("C" & rwIndex) = ""
rwIndex = rwIndex + 1
Loop
Range(Cells(1, 3), Cells(rwIndex, ColIndex)).Select
'
Range("C1:D20").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("C21:D40").Select
Selection.Sort Key1:=Range("C21"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'
Range("A1").Select
End Sub

It starts from C1 and continues looping until there is an empty cell in
Column C. Hence ColIndex being equal to 3.

Hope that this helps.
Kiza


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