|
楼主 |
发表于 2018-7-13 11:50
|
显示全部楼层
本帖最后由 海底有座冰城 于 2018-7-13 11:56 编辑
- Sub test()
- Dim Total As Boolean
- Dim count&
- Dim result(1 To 10000, 1 To 50)
- Dim arr
- Dim rows&, columns&, i&, j&
- rows = 1
- Application.ScreenUpdating = False
- For Each Key In Sheets
- If Key.Name <> "汇总" Then
- count = count + 1
- arr = Key.[a1].CurrentRegion.Value
- If count = 1 Then
- columns = UBound(arr, 2)
- For j = 1 To columns
- result(1, j) = arr(1, j)
- Next
- End If
- For i = 2 To UBound(arr)
- rows = rows + 1
- For j = 1 To UBound(arr, 2)
- result(rows, j) = arr(i, j)
- Next
- Next
- Else
- Total = True
- End If
- Next
- If Total = False Then
- Sheets.Add After:=Sheets(Sheets.count)
- Sheets(Sheets.count).Name = "汇总"
- End If
- With Sheets("汇总")
- .Cells.Clear
- .[a1].Resize(rows, columns).Value = result
- .Activate
- End With
- Application.ScreenUpdating = True
- End Sub
这是论坛中,相同问题,别人的代码,也不知道对不对,可是我不会VBA,还没学,看不懂,谁能根据我的表,帮我改一下,多谢了,如果你愿意,我想拜你为师。
|
|