试试看- Sub test()
- Dim i&, j&, k&, arr, brr(1 To 65536, 1 To 8), sh As Worksheet
- Dim lastcol&, lastrow&, t$
- Dim r&
- For Each sh In Sheets
- t = sh.Name
- If t <> "汇总表" And t <> "提取表" Then
- lastrow = sh.Cells(Rows.Count, "D").End(xlUp).Row
- lastcol = sh.Cells(5, Columns.Count).End(xlToLeft).Column
- arr = sh.Range("a5", sh.Cells(lastrow, lastcol))
- For j = 8 To UBound(arr, 2)
- For i = 3 To UBound(arr)
- If Val(arr(i, j)) > 0 Then
- r = r + 1
- For k = 1 To 5
- brr(r, k) = arr(i, k)
- Next
- brr(r, 6) = arr(1, j): brr(r, 7) = arr(i, j): brr(r, 8) = t
- End If
- Next
- Next
- End If
- Next
- Sheets("提取表").UsedRange.Offset(1).ClearContents
- Sheets("提取表").Cells(2, 1).Resize(r, UBound(brr, 2)) = brr
- End Sub
复制代码 |