|
楼主 |
发表于 2023-4-4 13:35
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 匹配系统信息()
Dim d As Object, Arr, Brr, Crr, dl, i&, s
Dim wb As Workbook
Set d = CreateObject("scripting.dictionary") '字典
Set dl = CreateObject("scripting.dictionary") '字典
Sheet1.Activate
[A2:B5000].ClearContents '清空
[D2:D5000].ClearContents '清空
Crr = Sheets("查询").[a1].CurrentRegion
Set wb = Workbooks.Open(ThisWorkbook.Path & "\数据源.xlsx") '打开数据源
'多条件查询
Arr = wb.Sheets("查询NR_DU小区静态参数").[a1].CurrentRegion '打开数据源查询NR_DU小区静态参数
For i = 2 To UBound(Arr)
d(Arr(i, 2) & Arr(i, 6)) = Array(Arr(i, 1), Arr(i, 5))
Next
'单条件查询
Brr = wb.Sheets("查询gNodeB功能").[a1].CurrentRegion
For i = 2 To UBound(Brr)
dl(Brr(i, 2)) = Brr(i, 5)
Next
'关闭数据源
wb.Close False
'单条件查询加取值前五位字符
For i = 2 To UBound(Crr)
If d.exists(Crr(i, 3) & Crr(i, 5)) Then
s = d(Crr(i, 3) & Crr(i, 5))
Crr(i, 1) = Left(s(0), 5)
Crr(i, 4) = s(1)
End If
If dl.exists(Crr(i, 3)) Then
Crr(i, 2) = dl(Crr(i, 3))
End If
Next
[a1].CurrentRegion = Crr
Set d = Nothing
Set dl = Nothing
End Sub
这个有个问题就是其它区域的公式会被粘贴为数值,可以限定下区域吗? |
|