我的代碼: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'的對象。 –