|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim flg As Boolean
- tt = Timer
- With Worksheets("sheet2")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- brr = .Range("a2:a" & r)
- End With
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a3:l" & r)
- ReDim crr(1 To UBound(arr) * 100, 1 To UBound(arr, 2))
- m = 0
- For i = 1 To UBound(arr)
- m = m + 1
- For j = 1 To UBound(arr, 2)
- crr(m, j) = arr(i, j)
- Next
- flg = False
- For k = 1 To UBound(brr)
- If brr(k, 1) Like arr(i, 3) & "*" Then
- m = m + 1
- crr(m, 3) = brr(k, 1)
- flg = True
- Else
- If flg Then
- Exit For
- End If
- End If
- Next
- Next
- End With
- With Worksheets("sheet3")
- .Range("a2").Resize(m, UBound(crr, 2)) = crr
- End With
- MsgBox Timer - tt
- End Sub
复制代码 |
|