|
试试看
Sub Macro1()
Dim arr, brr(), sh As Worksheet, i&, j&, s$, d As Object
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
With sh
If .Name <> ActiveSheet.Name Then
arr = .[a1].CurrentRegion
For j = 1 To UBound(arr, 2)
If Not d.Exists(arr(1, j)) Then
m = m + 1
d(arr(1, j)) = m
End If
Next
End If
End With
Next
ReDim brr(1 To 60000, d.Count)
m = 0
For Each sh In Sheets
With sh
If .Name <> ActiveSheet.Name Then
s = .Name
arr = .[a1].CurrentRegion
For i = 2 To UBound(arr)
m = m + 1
brr(m, 0) = s
For j = 1 To UBound(arr, 2)
brr(m, d(arr(1, j))) = arr(i, j)
Next
Next
End If
End With
Next
ActiveSheet.UsedRange.ClearContents
[a1] = "工作表"
[b1].Resize(, d.Count) = d.keys
[a2].Resize(m, d.Count + 1) = brr
End Sub |
|