I am currently working on a project and I am looking for some help. To give you guys a mockup of what's going on, I will run the script step by step.
1) I currently have a string array called "AnimalNamesToRemove" (for this example, the array contains the following words) that contains the words that are used as bookmarks in the text document that I am looking to remove from the word table below:
AnimalNamesToRemove
AnimalCat, AnimalDog, AnimalBird
2) In addition to the array, there is a table in a text document that has the name of the animal in the first column, as well as some information about the animal (the only information that matters is the name of the animal):
Word table

3) excel, , , , . , Excel, ( "myRangeRef" ):

4) , , , , , (, "AnimalDog" ) (, "" ), (, "" ) - , , "AnimalNamesToRemove" (, Cat, Dog, Bird), "AnimalsToDelete". , , , "AnimalsToDelete", (, Cat, Dog Bird) ( ), , , (. , )

Dim wdTable As Object
Dim myRangeRef As Range
Dim AnimalNamesToRemove As Variant
Dim AnimalsToDelete As Variant
Dim wdDoc As Object
Set myRangeRef = ThisWorkbook.Sheets("Bookmark References").Range("B1:B6")
Set wdTable = wdDoc.Tables(1)
For i = LBound(AnimalNamesToRemove) To UBound(AnimalNamesToRemove)
For Each cell In myRangeRef
If InStr(1, cell.Value, AnimalNamesToRemove(i), vbTextCompare) Then
aCell = cell.Offset(, -1).Value
stTemp = stTemp & "," & aCell
End If
Next cell
Next i
stTemp = Mid(stTemp, 2)
If Not Len(Trim(stTemp)) = 0 Then
AnimalsToDelete = Split(stTemp, ",")
For i = LBound(AnimalsToDelete) To UBound(AnimalsToDelete)
For j = wdTable.Rows.Count To 2 Step -1
If wdTable.cell(j, 1).Range.Text = AnimalsToDelete(i) Then wdTable.Rows(j).Delete
Next j
Next i
End If
- / , .
.. (.. "set wdTable =" "next i" ), , .
,