amitash
08-29-2012, 01:47 AM
Hi ALL,
I want to write a macro that can sort the column A (and other columns' values will be sorted accordingly) in whatever worksheets. I try to record the sorting and edit the code. But the problem I face is I don't know what to put inside the ListObjects(), any idea?
Range("A2").Select
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table_owssvr_1279").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table_owssvr_1279").Sort. _
SortFields.Add Key:=Range("A2"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(wsName).ListObjects("Table_owssvr_1279").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
I want to write a macro that can sort the column A (and other columns' values will be sorted accordingly) in whatever worksheets. I try to record the sorting and edit the code. But the problem I face is I don't know what to put inside the ListObjects(), any idea?
Range("A2").Select
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table_owssvr_1279").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table_owssvr_1279").Sort. _
SortFields.Add Key:=Range("A2"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(wsName).ListObjects("Table_owssvr_1279").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With