I have a word table that is populated by Excel VBA as shown below:-
In some instances it places an "X" in column 1 as shown below
https://res.cloudinary.com/engineering-com/image/upload/v1664898803/tips/word_table_z0jjzg.jpg
I use the following code to successfully to delete other rows with the "X", but it is failing to delete these two and I cannot fathom why. Any help apprecaited.
[codeWith wordDoc.Tables(4)
For r = 1 To .Rows.Count
If .Cell(r, c).Range.Text Like "*" & "X" & "*" Then
wordDoc.Tables(4).Rows(r).Delete
End If
Next r
End With[/code]
Code:
wordDoc.Tables(4).Cell(2, 1).Range.Text = " " & Range("O19").Value & " Way Flush Mounting, Programmable Alarm Annunciator." 'Product code
wordDoc.Tables(4).Cell(5, 1).Range.Text = Range("O25").Value 'Window size
wordDoc.Tables(4).Cell(8, 1).Range.Text = Range("O13").Value & "W" & Range("O14").Value & "H" 'Panel Size
wordDoc.Tables(4).Cell(12, 1).Range.Text = Range("O26").Value 'Pushbutton
wordDoc.Tables(4).Cell(14, 1).Range.Text = Range("O19").Value & "A" 'Channel Count
wordDoc.Tables(4).Cell(15, 1).Range.Text = Range("P24").Value ' Unarmed
wordDoc.Tables(4).Cell(16, 1).Range.Text = Range("R25").Value 'Illumination
wordDoc.Tables(4).Cell(17, 1).Range.Text = Range("O27").Value 'RR
wordDoc.Tables(4).Cell(18, 1).Range.Text = Range("R26").Value 'Trop
wordDoc.Tables(4).Cell(19, 1).Range.Text = Range("O29").Value 'FCV
wordDoc.Tables(4).Cell(20, 1).Range.Text = Range("P33").Value 'Comms
wordDoc.Tables(4).Cell(21, 1).Range.Text = Range("P32").Value 'GFI
wordDoc.Tables(4).Cell(22, 1).Range.Text = Range("L44").Value 'Logo
wordDoc.Tables(4).Cell(24, 1).Range.Text = Range("O28").Value 'SEC
wordDoc.Tables(4).Cell(29, 1).Range.Text = Range("Q76").Value 'Option
wordDoc.Tables(4).Cell(30, 3).Range.Text = Range("B3").Value 'Part number
In some instances it places an "X" in column 1 as shown below
https://res.cloudinary.com/engineering-com/image/upload/v1664898803/tips/word_table_z0jjzg.jpg
I use the following code to successfully to delete other rows with the "X", but it is failing to delete these two and I cannot fathom why. Any help apprecaited.
[codeWith wordDoc.Tables(4)
For r = 1 To .Rows.Count
If .Cell(r, c).Range.Text Like "*" & "X" & "*" Then
wordDoc.Tables(4).Rows(r).Delete
End If
Next r
End With[/code]