|
发表于 2024-7-24 17:35
来自手机
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 汇总()
Dim i&, j&, X, Arr
iMsg = MsgBox("是否清除原有数据?", 4 + 32)
If iMsg = 6 Then Worksheets(1).[A1].CurrentRegion.Offset(1, 0).ClearContents
For i = 2 To Sheets.Count
With Worksheets(i)
X = .[F1].Value
Arr = .[A1].CurrentRegion.Offset(2, 0)
End With
With Worksheets(1)
With .Cells(Rows.Count, 2).End(xlUp)
.Offset(1, 0).Resize(UBound(Arr), UBound(Arr, 2)) = Arr
.Offset(1, -1).Resize(UBound(Arr) - 2, 1) = X
End With
End With
Erase Arr
Next i
End Sub |
|