excel如何用宏在满足特定条件时替换指定文字?

2024-11-20 20:25:47
推荐回答(1个)
回答1:

Set d = CreateObject("Scripting.Dictionary")
For i = 1 To [b1048576].End(xlUp).Row
If Not Range("b" & i).Find(";", , xlValues, xlPart) Is Nothing Then d.Add Split(Range("b" & i), ";")(1), Split(Range("b" & i), ";")(0)
Next
For i = 1 To [a1048576].End(xlUp).Row
If Not Range("a" & i).Find(";", , xlValues, xlPart) Is Nothing Then Range("a" & i) = Replace(Range("a" & i), Split(Range("a" & i), ";")(0) & ";" & Split(Range("a" & i), ";")(1), d.Item(Split(Range("a" & i), ";")(1)) & ";" & Split(Range("a" & i), ";")(1))
Next