大家都知EXCEL只能按列排序,
此代码能让EXCEL实现按行排序的功能
Sub Macro1()
Dim i As Integer
For i = 2 To Sheet1.Range("a65535").End(xlUp).Row
Rows(i).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
Selection.Copy
Sheets("Sheet1").Select
Rows(i).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Cells(i, 1).Select
Next
End Sub
(2013-02-05, VBA, 8KB, 下载6次)