Sub 多表合并()
Dim wsh As Worksheet, brr()
For Each wsh In Worksheets 工作薄里好多工作表,想指定查询表3,表4,表5该如何改代码啊?就是把这些表的数据都复制到一张新表上。
If wsh.Name <> "汇总" Then
arr = wsh.Range("a2:p" & wsh.Range("a65536").End(xlUp).Row)
k = k + UBound(arr)
ReDim Preserve brr(1 To 15, 1 To k)
For i = 1 To UBound(arr)
n = n + 1
brr(1, n) = arr(i, 1)
brr(2, n) = arr(i, 2)
brr(3, n) = arr(i, 3)
brr(4, n) = arr(i, 4)
brr(5, n) = arr(i, 5)
brr(6, n) = arr(i, 6)
brr(7, n) = arr(i, 7)
brr(8, n) = arr(i, 8)
brr(9, n) = arr(i, 9)
brr(10, n) = arr(i, 10)
brr(11, n) = arr(i, 11)
brr(12, n) = arr(i, 12)
brr(13, n) = arr(i, 13)
brr(14, n) = arr(i, 14)
brr(15, n) = arr(i, 15)
Next
End If
Next
Sheets("汇总").Range("a2").Resize(n, 15) = Application.WorksheetFunction.Transpose(brr)
End Sub
|