首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >vba,错误消息,vba引用,regex

vba,错误消息,vba引用,regex
EN

Stack Overflow用户
提问于 2020-10-22 12:25:15
回答 1查看 56关注 0票数 0

我收到一条错误消息。

代码语言:javascript
复制
    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,以准确计算数据。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-22 12:38:56

有两个版本的库Microsoft VBScript Regular Expressions,1.0和5.5。您收到的错误消息显示您使用的是旧版本的1.0。把它换成新版本。根本不要使用1.0。添加引用的顺序可能会导致早期版本隐藏更新版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64482165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档