VBA 将数组元素通过字典实现替换
文件请到网盘下载链接:http://pan.baidu.com/s/1bnvmokJ密码:h6e2...
文件请到网盘下载
链接: http://pan.baidu.com/s/1bnvmokJ 密码: h6e2 展开
链接: http://pan.baidu.com/s/1bnvmokJ 密码: h6e2 展开
1个回答
展开全部
Option Explicit
Sub xxx()
Dim d, i, j, arr
Set d = CreateObject("scripting.dictionary")
i = 2
While Cells(i, "E") <> ""
d(Trim(Cells(i, "E"))) = Trim(Cells(i, "F"))
i = i + 1
Wend
i = 2
While Cells(i, "A") <> ""
arr = Split(Trim(Cells(i, "A")), "-")
For j = LBound(arr) To UBound(arr)
If d.Exists(arr(j)) Then arr(j) = d(arr(j))
Next j
Cells(i, "B") = Join(arr, "-")
i = i + 1
Wend
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询