bugfix> vba > 投稿


   Public Sub My_Split()
    Dim z As Variant
    z = Split(Replace(Join(Filter(Split(Replace(Replace(Selection.Value, "<" , ">")
    Selection.Offset(0, 1).Resize(, UBound(z) + 1) = z
     End Sub

回答 1 件
  • Sub simpleRegex()
    Dim strPattern As String: strPattern = " <([a-z] | [A-Z] | [0-9] | \. | - | _)+>"
    Dim Match As Object
    Dim matches As Object
    Dim regex As Object
    Set regex = CreateObject("VBScript.RegExp")
    Dim strInput As String
    Dim Myrange As Range
    Set Myrange = ActiveSheet.Range("D8:D10")
    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
                Set matches = regex.Execute(strInput)
                For Each Match In matches
                    MsgBox (Match.Value) 'A workaround I found to see if my pattern
                                         'worked but I need to print Match.value
                                         'in a column so this wont do
                MsgBox ("Not matched")
            End If
        End If
    End Sub