Hi All,
The following code has some issues.it is working when all rows are same but whenever it needs to sort a sheet with variable rows , it is selecting the cells but not sorting. Pls Help.
The following code has some issues.it is working when all rows are same but whenever it needs to sort a sheet with variable rows , it is selecting the cells but not sorting. Pls Help.
Code:
Sub Sort()
Dim i As Long
Dim LastARow As Integer
LastARow = Range("A11").End(xlDown).Offset(-3, 0).Row
For i = 14 To Worksheets.count
Rows("11:11").Select
Range(Selection, Selection.End(xlDown).Offset(-3, 0)).Select
With Worksheets(i).Select
With Worksheets(i).Sort
.SortFields.Clear
.SortFields.Add Key:=Range("C11:C" & LastARow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
.SortFields.Add Key:=Range("A11:A" & LastARow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
.SortFields.Add Key:=Range("B11:B" & LastARow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
.SetRange Range("A11:IU" & LastARow)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
Next
End Sub