1

I am trying to assign a match object value to a cell value, but it is giving me compile error

Method or Data Member not found

I believe I would probably have the syntax wrong, but even after consulting online tutorials and examples, I cannot deduce what the correct syntax would be for my code.

I have looked at different examples on the web. I found this one website that showed what should have worked for me, but even that did not. https://developer.rhino3d.com/guides/rhinoscript/vbscript-regexp-objects/

This is my code.

    Dim rng As Range
    Set rng = Range("a3")

    Dim ObjRegex As RegExp
    Set ObjRegex = New RegExp

    Dim matches As MatchCollection

    With ObjRegex
        .Pattern = "^Total:"
        .Global = True
        .IgnoreCase = True
            Set matches = .Execute(rng)
    End With

    If matches.Count = 1 Then
    Range("b1").Value = matches.Value
    End If

End Sub

Ultimately, If the cell value has a match of the regex pattern then I want to copy the cell contents to another address.

Note: I have tested, and the regex does work and give a match. The problem is in the if statement

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Varun Khanna
  • 85
  • 12
  • 4
    Your error tells you `matches` has no `.Value`. Even if `matches.Count` is only 1 it is an array of matches. Try `Range("b1").Value = matches(0)` instead. – Pᴇʜ Apr 29 '19 at 10:14

0 Answers0