|
Option Explicit
Sub TEST2()
Dim ar(), br, i&, j&, k&, n&, r&, c&, wks As Worksheet
Application.ScreenUpdating = False
For Each wks In Worksheets
If wks.Name <> "Sheet1" Then
n = n + 1
ReDim Preserve ar(1 To n)
ar(n) = wks.[A1].CurrentRegion.Value
If UBound(ar(n)) > r Then r = UBound(ar(n))
If UBound(ar(n), 2) > c Then c = UBound(ar(n), 2)
End If
Next
ReDim br(1 To r, 1 To c)
For i = 1 To UBound(ar)
For k = 1 To UBound(ar(i))
br(k, 1) = ar(i)(k, 1)
Next k
For j = 2 To UBound(ar(i), 2)
For k = 1 To UBound(ar(i))
If Len(ar(i)(k, j)) Then br(k, j) = ar(i)(k, j)
Next k
Next j
Next i
With Worksheets("Sheet1")
.Cells.Clear
With .[A1].Resize(r, c)
.Value = br
.HorizontalAlignment = xlCenter
.Borders.LineStyle = xlContinuous
.EntireColumn.AutoFit
.Rows(1).Interior.Color = vbYellow
End With
.Activate
End With
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
2
查看全部评分
-
|