View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Janis Janis is offline
external usenet poster
 
Posts: 360
Default Help wanted with VBA code

You need to give more information if you want to get explicit help on which
columns you want to sort on and whether you have a header row of field names.
I don't think you need to find the range unless you only want to sort on a
range instead of the whole sheet. Here is an example of my sort on 3 columns
with the 3 labels in the first row as the matching key.

Sub Sort()


Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 26).End(xlUp))
MsgBox rng.Address
rng.Sort key1:=.Cells(1, 16), Order1:=xlAscending, _
key2:=.Cells(1, 19), Order2:=xlAscending, _
key3:=.Cells(1, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom
End With


End Sub


" wrote:

i want to write a macro
that would contain a do loop
and within that do loop i want to do sorting

can any one help i cant understand of how to select the cells that i
want to sort in VBA language


hope i have made my self clear

thanking you in advance


regards
indraneel