排序命令有效。如果excel宏试图操作由宏打开的工作表,则相同的排序命令不起作用。
With ActiveWorkbook.Worksheets("Sheet").Sort
.SetRange Range("A1:D" & replacementRow - 1)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
用于打开工作簿的语句
Workbooks.Open (Cells(1, 1))
答案 0 :(得分:1)
我假设你有一个Cell(1,1)工作簿的链接?如果是这样,试试:
Dim wb As Workbook
Set wb = Workbooks.Open(Cells(1, 1))
With wb.Worksheets("Sheet1").Sort
.SetRange Range("A1:D" & replacementRow - 1)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With