如何在HTA中使用excel Macro recorder中记录的以下代码?
Sub Macro1()
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:= _
Range("M2:M9"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:= _
Range("B2:B9"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:M9")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
我可以定义范围,工作表名称等。但是无法将属性设置为排序:(
谢谢, 阿南德
答案 0 :(得分:0)
Set objRange1 = objExcel.Range("M1") Set objRange2 = objExcel.Range("A1") objRange.Sort objRange1, xlAscending, objRange2, , xlAscending, , , xlYes