Consulting

Results 1 to 3 of 3

Thread: Find string in Excel sheet from Word doc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Find string in Excel sheet from Word doc

    Hi,
    i have a macro that reads a selection in a (open) word file
    and i want to find this selection in the 2nd column of a worksheet
    and copy the cell value of the 4th column (same row).
    I've tried several methods with no success.
    I ask for your help for the [find] section and the selection of the cell in 4th column.

    This reads all cells in the 2nd column but doesn't find the string from Word (r) that exists in 10th row.

        With wb.Sheets("new_prices").Range("b1")    '<---------------------   wb is the open excel file
            For idx = 1 To .CurrentRegion.Rows.Count
                With Selection.Find
                    .Forward = True
                    .ClearFormatting
                    .MatchWholeWord = False
                    .MatchCase = False
                    .Wrap = wdFindContinue
                    .Text = r  '<-------------------------------------- string from Word
                    If .Execute = True Then
                            ..............................
                            ..............................
                    End If
                End With
            Next
        End With
    Thanks
    Last edited by Aussiebear; 12-28-2021 at 02:06 PM. Reason: Added code tags to supplied code

Posting Permissions

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