|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下
- Private Sub CommandButton1_Click()
- Dim arr, i%, j%, br, crr, d
- Set d = CreateObject("scripting.dictionary")
- With Sheet1
- arr = .[a2].Resize(.[a2].End(4).Row, 1)
- br = .[b2].Resize(.[b2].End(4).Row, 1)
- ReDim crr(1 To UBound(arr), 1 To UBound(br))
- For i = 1 To UBound(arr)
- For j = 1 To UBound(br)
- If InStr(arr(i, 1), br(j, 1)) Then
- d(br(j, 1)) = d(br(j, 1)) + 1
- crr(1, j) = br(j, 1)
- crr(d(br(j, 1)) + 1, j) = arr(i, 1)
- Exit For
- End If
- Next j
- Next i
- End With
- Sheet2.[a1].Resize(UBound(crr), UBound(br)) = crr
- Set d = Nothing
- End Sub
复制代码 |
|