如何使用excel系列中的regexp模式进行批量替换,请参阅下面的答案:
答案 0 :(得分:1)
以下是使用基于RegExp的其他范围的列表在Excel范围内进行替换的方法:
Sub regexpreplace()
Set Myrange = ActiveSheet.Range("A2:A1000") 'range in which we make replace
Set regrange = ActiveSheet.Range("B2:B6") 'range with RegExp pattern
'in range C1:C6 we have pattern for replace
For Each D In regrange
For Each C In Myrange
Set rgx = CreateObject("VBScript.RegExp")
rgx.IgnoreCase = True
rgx.Pattern = D.Value
rgx.Global = True
C.Value = rgx.Replace(C.Value, D.Offset(0, 1).Value)
Next
Next
End Sub
在此代码中: