|
本帖最后由 hwc2ycy 于 2012-11-24 23:37 编辑
- Sub Test555()
- Dim iRow, x, arr1(1 To 165536, 1 To 1), i, K
- Dim TRow&, URow&
- iRow = Range("A:A").Find(what:="M30").Row
- x = Range("T:T").Find("", LookIn:=xlValues).Row - 1
- TRow = Range("t" & Rows.Count).End(xlUp).Row
- URow = Range("u" & Rows.Count).End(xlUp).Row
- If TRow = 1 And URow = 1 Then MsgBox "没有增加数据": Exit Sub
- x = IIf(TRow > URow, TRow, URow)
- arr = Range("T2:U" & x)
- For i = 1 To UBound(arr)
- If i = 1 Then
- If Len(arr(i, 1)) Then K = K + 1: arr1(K, 1) = arr(i, 1)
- If Len(arr(i, 2)) Then K = K + 1: arr1(K, 1) = arr(i, 2)
- ElseIf arr(i, 1) = arr(i - 1, 1) Then
-
- If Len(arr(i, 2)) Then K = K + 1: arr1(K, 1) = arr(i, 2)
- Else
- If Len(arr(i, 1)) Then K = K + 1: arr1(K, 1) = arr(i, 1)
- If Len(arr(i, 2)) Then K = K + 1: arr1(K, 1) = arr(i, 2)
- End If
- Next
- Application.ScreenUpdating = False
- Application.Calculation = xlManual
- Range("A" & iRow).Resize(K).Insert Shift:=xlDown
- Range("A" & iRow).Resize(K) = arr1
- Application.ScreenUpdating = True
- Application.Calculation = xlAutomatic
- End Sub
复制代码 |
|