|
楼主 |
发表于 2014-7-29 16:55
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
SycoVictor 发表于 2014-7-29 00:16
这样行不行。
批注可否加上总装出库数呢?如果合并了,那是否有两个批注?
Sub test()
Dim i&
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With GetObject(ThisWorkbook.path & "\" & Cells(1, 1) & ".xls")
Range(Worksheets(2).Cells(4, 43 + Int(Right(Worksheets(1).Cells(1, 1), 2))), Worksheets(2).Cells(4, 43 + Int(Right(Worksheets(1).Cells(1, 1), 2))).End(3).Offset(1, 0)).ClearContents
For i = 2 To .Worksheets(1).Cells(65536, 1).End(3).Row
For j = 2 To Worksheets(2).Cells(65536, 1).End(3).Row
If .Worksheets(1).Cells(i, 10) = Worksheets(2).Cells(j, 2) Then
Worksheets(2).Cells(j, 43 + Int(Right(.Worksheets(1).Cells(i, 2), 2))) = Worksheets(2).Cells(j, 43 + Int(Right(.Worksheets(1).Cells(i, 2), 2))) + .Worksheets(1).Cells(i, 6)
Worksheets(2).Cells(j, 43 + Int(Right(.Worksheets(1).Cells(i, 2), 2))).Comment.Text Text = "Worksheets(1).Cells(i, 1) & Worksheets(1).Cells(i, 3)"
End If
Next
Next
.IsAddin = True
.IsAddin = False
.Close True
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
|