我的代码:VBA错误:方法或数据成员找不到
Public Sub splitUpRegexPattern()
Dim regEx As New RegExp
Dim strPattern As String
Dim strInput As String
Dim strReplace As String
Dim Myrange As Range
Set Myrange = ActiveSheet.Range("B2:B4279")
For Each c In Myrange
strPattern = "([A-Z]{2}\/[A-Z]{2}\/[A-Z][0-9]{2}\/[a-z]{3}[0-9]{9}\/)([0-9]{4})"
If strPattern <> "" Then
strInput = c.Value
strReplace = "$1"
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.test(strInput) Then
c.Offset(0, 1) = regEx.Replace(strInput, "$2")
Else
c.Offset(0, 1) = ""
End If
End If
Next
末次
它最初运作良好,它会给我一个错误,但仍然完成它的任务这样做。但是,当我用这个宏在新的电子表格,它给我的错误:
Compile Error: Method or Data Member not found.
所有在这个网站解决方案是针对不同的情况,所以我不能不幸的是它们适用于我的情况。
我不知道为什么会发生这种情况,因为我没有更改任何代码。我相信,如果我对VBA脚本有了更深入的了解,我就能理解这一点,但我不知道,所以我来找出这里有人能帮助我!
谢谢!
艾丹
可能是你正在一个实例'RegExp'的对象。 –