我收到一条错误消息。
Compile error: Method or data member not found
Line causing Error: It highlights Sub Macro1() and after I click ok, it selects: .MultiLine =
I just saved it as a macro enabled workbook. Now getting: Compile error. Method or data member not found. Error goes to same place.为什么代码会收到此错误消息?我使用的是VBA引用: Microsoft正则表达式1.0和Microsoft正则表达式5.5。我使用的是VBA,因为我需要在我的电子表格上使用Regex。我需要将任何类似3_CELL_VALUE或2_CELL_VALUE的内容更改为1_CELL_VALUE,以准确计算数据。
Sub Macro1()
Dim strPattern As String: strPattern = "[0-9]_CELL_VALUE"
Dim strReplace As String: strReplace = "1_CELL_VALUE"
Dim regEx As New RegExp
Dim strInput As String
Dim Myrange As Range
Set Myrange = Worksheets("Data").Range("$A$1:$A$9999")
For Each cell In Myrange
If strPattern <> "" Then
strInput = cell.Value
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.Test(strInput) Then
MsgBox (regEx.Replace(strInput, strReplace))
Else
MsgBox ("Not matched")
End If
End If
Next
End Sub发布于 2020-10-22 12:38:56
有两个版本的库Microsoft VBScript Regular Expressions,1.0和5.5。您收到的错误消息显示您使用的是旧版本的1.0。把它换成新版本。根本不要使用1.0。添加引用的顺序可能会导致早期版本隐藏更新版本。
https://stackoverflow.com/questions/64482165
复制相似问题