|
详见代码
- Sub Sh3自动添加新增条目() 'sheet3
- Application.ScreenUpdating = False
- Application.AutomationSecurity = msoAutomationSecurityForceDisable
- Filename = "H:\金豪利 2019\订单管理系统V2.1.xlsm"
- Set wb = Workbooks.Open(Filename)
- Set sht = wb.Worksheets("电镀件信息")
- Dim a, d, i%, r%
- Set d = CreateObject("Scripting.dictionary")
- a = Sheet3.[a1].CurrentRegion
- For i = 3 To UBound(a)
- d(a(i, 1) & "丨" & a(i, 2) & "丨" & a(i, 3)) = 0
- Next
- r = Sheet3.[b65536].End(3).Row + 1
- a = sht.Range("A3:C" & sht.[a65536].End(xlUp).Row)
- For i = 1 To UBound(a)
- If Not d.exists(a(i, 1) & "丨" & a(i, 2) & "丨" & a(i, 3)) Then
- Sheet3.Range("A" & r & ":C" & r) = Application.Index(a, i)
- r = r + 1
- End If
- Next
- wb.Close
- Set wb = Nothing
- Set sht = Nothing
- Application.AutomationSecurity = msoAutomationSecurityLow
- Application.ScreenUpdating = True
- End Sub
复制代码 代码无报错。
|
|