2
我正尝试使用VBA在Excel文件中按升序对列D进行排序。我想扩展A-F列中所有值的选择。按升序排列Excel列并扩展选择的VBA代码?
我用这个公式为出发点:
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
http://msdn.microsoft.com/en-us/library/office/ff840646(v=office.15).aspx –