Hi
I am trying to modify this recorded code. I tried, but failed.
In an active worksheet, I am trying to select a few rows and want to sort them by column "K"
I would appreciate if someone can modify this for me.
Thanks
FLDS
Code: I recorded
Sub Sort2()
'
' Sort2 Macro
'
With Selection 'I added this row
' Rows("29:54").Select 'I stopped this row
ActiveWorkbook.Worksheets("Record").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Record").Sort.SortFields.Add Key:=Range("K29:K54"), _ 'I want to select the range
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Record").Sort
.SetRange Range("A29:X54") 'I want to select the rows
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With 'I added this row
End Sub
I am trying to modify this recorded code. I tried, but failed.
In an active worksheet, I am trying to select a few rows and want to sort them by column "K"
I would appreciate if someone can modify this for me.
Thanks
FLDS
Code: I recorded
Sub Sort2()
'
' Sort2 Macro
'
With Selection 'I added this row
' Rows("29:54").Select 'I stopped this row
ActiveWorkbook.Worksheets("Record").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Record").Sort.SortFields.Add Key:=Range("K29:K54"), _ 'I want to select the range
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Record").Sort
.SetRange Range("A29:X54") 'I want to select the rows
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With 'I added this row
End Sub