返回列表 上一主題 發帖

橫向排序問題

回復 1# pcwh3
  1. Sub SORT()
  2. Dim ARR()
  3. R = 1
  4. Do Until Cells(R, "A") = ""
  5.    LastC = Cells(R, 256).End(xlToLeft).Column
  6.    ReDim ARR(LastC)
  7.    For C = 1 To LastC
  8.      ARR(C) = WorksheetFunction.Small(Range("A" & R).Resize(1, LastC), C)
  9.    Next C
  10.    For C = 1 To LastC
  11.      Cells(R, C) = ARR(C)
  12.    Next C
  13.    R = R + 1
  14. Loop
  15. End Sub
複製代碼

TOP

回復 5# pcwh3
  1. Sub SORT()
  2. For R = 6 To [A65536].End(xlUp).Row
  3.     If Cells(R, "G") <> "" Then
  4.        Range(Cells(R, "G"), Cells(R, "G").End(xlToRight)).Select
  5.        Selection.SORT Key1:=Cells(R, "G"), Order1:=xlAscending, Header:=xlGuess, _
  6.          OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, SortMethod _
  7.          :=xlStroke, DataOption1:=xlSortNormal
  8.        R = R + 1
  9.     End If
  10. Next R
  11. End Sub
複製代碼

TOP

        靜思自在 : 世上有兩件事不能等:一、孝順 二、行善。
返回列表 上一主題