Results 1 to 20 of 22

Thread: Find different expressions in same text (wildcard)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #19
    VBAX Regular
    Joined
    Apr 2020
    Posts
    12
    Location
    It's the first best choice, Macropod. But I need to discover the second best way to solve my problem. I will keep trying. These posts will be so helpful.

    Quote Originally Posted by macropod View Post
    Regardless, as I have already demonstrated, there is no need for Find if the data are in a table.

    I have just found a way to do this.

    Sub FindIt()
        Dim blnFound As Boolean
        Dim rng1 As Range
        Dim rng2 As Range
        Dim rngFound As Range
        Dim strTheText As Variant
        Dim firstWd
        Dim lastWd    
        firstWd = Array("Full name:", "ID:", "SOCIAL INSURANCE NUMBER:", "ADDRESS:", "Zip code:", "E-mail:", "Phone number:")    
        lastWd = Array("2. ID:", "3. SOCIAL INSURANCE NUMBER:", "4. ADDRESS:", "4.1 Zip code:", "5. E-mail", "6. Phone number", "7. Graduate") 
        Application.ScreenUpdating = False    
        For i = 0 To UBound(firstWd)
             Selection.HomeKey wdStory
             Selection.Find.Text = firstWd(i)
             blnFound = Selection.Find.Execute
             If blnFound Then
                 Selection.MoveRight wdWord
                 Set rng1 = Selection.Range
                 Selection.Find.Text = lastWd(i)
                 blnFound = Selection.Find.Execute
                 If blnFound Then
                     Set rng2 = Selection.Range
                     Set rngFound = ActiveDocument.Range(rng1.Start, rng2.Start)
                     strTheText = strTheText & "|" & rngFound.Text                    
                 End If
             End If
         Next                    
         MsgBox strTheText        
          ' move back to beginning
          Selection.HomeKey wdStory
          Application.ScreenUpdating = True
    End Sub

    Now I need to put this in Excel with previous file that exists and is open.
    Last edited by Aussiebear; 03-06-2025 at 04:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •