|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
公司网络传不了附件,写得不好,请测试
- Sub hb()
- Dim sh As Worksheet, i%, n%, k%, z%, x%, y%
- Application.ScreenUpdating = False
- For Each sh In Sheets
- sh.Activate
- n = Cells(Rows.Count, 1).End(3).Row
- For i = 2 To n
- Cells(i, 15) = Cells(i, 1) & Cells(i, 2) & Cells(i, 3) & Cells(i, 4)
- Next
- Next
- x = Worksheets.Count - 1
- If Sheets(Worksheets.Count).Cells(2, 15) = "" Then
- Set Rng = Sheets(Worksheets.Count).Cells(2, 15)
- Else
- Set Rng = Sheets(Worksheets.Count).Range(Cells(2, 15), Cells(Rows.Count, 15))
- End If
-
- For y = 1 To x
- Sheets(y).Activate
- n = Cells(Rows.Count, 1).End(3).Row
- For k = 2 To n
- Sheets(y).Activate
- If Rng.Find(Cells(k, 15)) Is Nothing Then
- Range(Cells(k, 1), Cells(k, 13)).Copy
- Sheets(Worksheets.Count).Activate
- z = Cells(Rows.Count, 1).End(3).Row
- Cells(z, 1).Offset(1, 0).Select
- Sheets(Worksheets.Count).Paste
- End If
- Next
- Next
- For y = 1 To x + 1
- Sheets(y).Activate
- Range(Cells(2, 15), Cells(Rows.Count, 15).End(3)).Clear
- [A1].Select
- Next
- MsgBox "汇总完成!"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|