vba拆分单元格并查找下划线数组

时间:2016-07-25 17:55:35

标签: arrays excel excel-vba vba

在代码运行之下并拉出之前的字样"如何"无论它出现在细胞中多少次。我需要帮助的是no,删除带下划线和斜体的单词。我知道使用相同的数组拆分方法可以工作,但我不知道如何实现它来查找带下划线和斜体的单词。在下面的示例中,我希望" pullout"和"你"也被移到第二张纸上。任何帮助表示赞赏。

enter image description here

enter image description here



Sub Te()
    Dim c As Range, v As String, arr, x As Long, e
    Dim d As Range
    Dim ws As Worksheet

  
    Set d = Worksheets("Sheet2").Range("B4") 
    
    For Each c In ActiveSheet.Range("C1:C105")
        v = Trim(c.Value)
        If Len(v) > 0 Then

            v = Replace(v, vbLf, " ")
            
            Do While InStr(v, "  ") > 0
                v = Replace(v, "  ", " ")
            Loop

            arr = Split(v, " ")
            For x = LBound(arr) To UBound(arr)
                e = arr(x)
                
                If Not IsError(Application.Match(LCase(e), Array("how"), 0)) Then
                    If x > LBound(arr) Then
                        d.Value = arr(x - 1) & " " & e
                    Else
                        d.Value = "??? " & e
                    End If
                    Set d = d.Offset(1, 0)
                End If
            Next x
        End If
   Next c
End Sub

​




0 个答案:

没有答案