|
- Sub 按钮1_Click()
- Dim rng As Range
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- Application.ScreenUpdating = False
- For j = 2 To UBound(arr)
- If Len(arr(j, 2)) = 0 Then
- d(arr(j, 1) & arr(j, 4)) = j
- Else
- d(arr(j, 2)) = j
- End If
- Next j
-
- r = UBound(arr) + 1
- arr = Sheets("新2").UsedRange
- For j = 2 To UBound(arr)
- If Len(arr(j, 2)) = 0 Then
- If Not d.exists(arr(j, 1) & arr(j, 4)) Then
- If rng Is Nothing Then
- Set rng = Sheets("新2").Cells(j, 1).Resize(1, 4)
- Else
- Set rng = Union(rng, Sheets("新2").Cells(j, 1).Resize(1, 4))
- End If
- End If
- Else
- If Not d.exists(arr(j, 2)) Then
- If rng Is Nothing Then
- Set rng = Sheets("新2").Cells(j, 1).Resize(1, 4)
- Else
- Set rng = Union(rng, Sheets("新2").Cells(j, 1).Resize(1, 4))
- End If
- Else
- Sheets("新2").Cells(j, 1).Resize(1, 4).Copy Cells(d(arr(j, 2)), 1)
- End If
- End If
- Next j
- If Not rng Is Nothing Then rng.Copy Cells(r, 1)
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|