|
瞬间完成 单表动态字段合并成一表- Sub 动态字段单薄多表合并为一表()
- Dim d, ar, br, sh As Worksheet
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- For Each sh In Sheets
- qsl = sh.UsedRange.Column
- qsh = sh.UsedRange.Row
- zdh = sh.Cells(65536, qsl).End(xlUp).Row
- If sh.Name <> ActiveSheet.Name Then
- If zdh > 1 Then
- ar = sh.Cells(qsh, qsl).CurrentRegion
- For i = 1 To UBound(ar, 2)
- d(ar(1, i)) = 0
- Next
- End If
- End If
- Next
- ReDim br(1 To 60000, 1 To d.Count): m = 1
- For i = 1 To d.Count
- d(d.keys()(i - 1)) = i
- br(1, i) = d.keys()(i - 1)
- Next
- For Each sh In Sheets
- qsl = sh.UsedRange.Column
- qsh = sh.UsedRange.Row
- zdh = sh.Cells(65536, qsl).End(xlUp).Row
- If sh.Name <> ActiveSheet.Name Then
- If zdh > 1 Then
- ar = sh.Cells(qsh, qsl).CurrentRegion
- For i = 2 To UBound(ar)
- m = m + 1
- For j = 1 To UBound(ar, 2)
- br(m, d(ar(1, j))) = ar(i, j)
- Next
- Next
- End If
- End If
- Next
- With ActiveSheet
- .UsedRange.ClearContents
- .[a1].Resize(m, UBound(br, 2)) = br
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|