【发布时间】:2016-11-04 22:14:59
【问题描述】:
我正在尝试使用 VBA 对 Excel 文件中的 D 列进行升序排序。我想扩大 A-F 列中所有值的选择范围。
我以这个公式为起点:
sort ascending/descending vba excel
它只对一列进行降序排序。我无法找到更多示例。
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
If (.Range("D2").Value > .Range("D" & CStr(LastRow))) Then
xlSort = xlAscending
End If
.Range("D2:D" & LastRow).Sort Key1:=.Range("D2"), Order1:=xlSort, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
【问题讨论】: