|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 字典查询_split()
- Dim arr, d As Object, i&, j&, m&
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("查询表").Range("A1").CurrentRegion
- If Not IsArray(arr) Then
- MsgBox "请输入查询数据再试。", vbInformation
- Exit Sub
- End If
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = ""
- Next
- arr = Sheets("数据源").Range("A1").CurrentRegion
- For i = 2 To UBound(arr)
- If d.Exists(Split(arr(i, 1), "_")(0)) Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- arr(m, j) = arr(i, j)
- Next
- End If
- Next
- If m > 0 Then
- With Sheets("结果表")
- .UsedRange.Offset(1) = ""
- .[a2].Resize(m, j - 1) = arr
- .[b1] = Timer - t
- .Activate
- End With
- Else
- MsgBox "没有查到相关信息。", vbInformation
- End If
- End Sub
- 'http://club.excelhome.net/thread-1184712-1-1.html
复制代码 |
|