Sub 合并各工作表内容()
sp = 0 '间隔
st = 9 '开如行数
Sheets(5).Select
Sheets.Add
For i = 7 To Sheets.Count
Sheets(i).Select
Set rng = Cells.Find("C. 标准工时")//这里是汇总到一个固定内容行
endnum = rng.Row - 1
zd = Cells(65536, 1).End(xlUp).Row
If zd > x Then
x = zd
End If
If x > endnum Then
x = endnum
End If
If y + x - st + 1 + sp > 65536 Then
MsgBox "内容太多,仅合并前" & i - 2 & "个表的内容,请把其它表复制到新工作薄里再用此程序合并!"
Else:
For j = st To x
If Cells(j, 1) <> "" And Cells(j, 1) <> "直接物料汇总金额" And Cells(j, 1) <> "B. 包装物料+生产辅料" Then
Rows(j).Select
Selection.Copy
Sheets(5).Select
Range("A" & CStr(y + 1)).Select
ActiveSheet.Paste
Sheets(i).Select
Range("A1").Select
Application.CutCopyMode = False
y = y + 1
End If
Next j
x = 0
End If
Next i
Sheets(5).Select
Range("A1").Select
MsgBox "这就是合并后的表,请命名!"
End Sub
EXCEL VBA 汇总工作表内容到一张表
最新推荐文章于 2024-01-20 16:23:17 发布