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

2024年11月20日 20:25
有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