|
我改了一下汇总工作表“sheet1”的工作表名为“汇总”,因为当用sheet1,程序出错,我还不知道什么原因。
你看看行不,我初步看没有问题,仔细看就没有了- Sub 汇总()
- Dim drow1%, drow2%, i%, j%, dcol%, k%, Arr, Brr(1 To 1000, 1 To 3)
- Dim sht As Worksheet
- For Each sht In ThisWorkbook.Worksheets
- If sht.Name <> "汇总" Then
- With sht
- drow1 = .[a65536].End(3).Row
- dcol = .Range("XFD2").End(xlToLeft).Column
- Arr = .Range(.Cells(1, 1), .Cells(drow1, dcol))
- End With
- Brr(1, 3) = Arr(1, 1)
- k = 1
- For i = 2 To drow1 Step 2
- For j = 1 To dcol Step 2
- If Arr(i, j) <> 0 Then
- Brr(k, 1) = Arr(i, j)
- Brr(k, 2) = Arr(i + 1, j)
- k = k + 1
- End If
- Next
- Next
- With Worksheets("汇总")
- drow2 = .[a65536].End(3).Row
- .Cells(drow2 + 1, 1).Resize(UBound(Brr), 3) = Brr
- End With
- Erase Brr
- End If
- Next sht
- MsgBox "汇总完成"
- End Sub
复制代码 |
|