程式碼:
Sub Ex()
Dim AR(), R As Range, C%, S%, Sh As Worksheet
For Each Sh In Sheets
If Sh.Name <> "總表" Then
With Sh
If S = 0 Then
ReDim Preserve AR(S)
AR(S) = .Range(.Range("A1"), .Range("A1").End(xlToRight))
C = .Range(.Range("A1"), .Range("A1").End(xlToRight)).Columns.Count
End If
For Each R In .Range(.[A2], .[a65536].End(xlUp))
S = S + 1
ReDim Preserve AR(S)
AR(S) = R.Resize(1, C)
Next
End With
End If
Next
With Sheets("總表")
.UsedRange = ""
.[A1].Resize(UBound(AR) + 1, C) = Application.Transpose(Application.Transpose(AR))
.Activate
.UsedRange.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess
End With
End Sub作者: GBKEE 時間: 2011-4-26 21:04