View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Carim
 
Posts: n/a
Default Easy question: Sort ascending in a row?

Hi Arjun,

If I understand correctly your data starts in B2 ...
following should do the job :

Sub Macro1()
Dim i As Integer
Dim Lr As Integer
Lr = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Range("B2").Select
For i = 2 To Lr
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Selection.Cells(1), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Next i
Range("A1").Select
End Sub

HTH
Cheers
Carim