vba Word表格批量删除含有某一字符的指定行
Sub del_key()
Dim str As String
Dim table_count, i, j, table_lie As Integer
str = "年度"
table_count = ActiveDocument.Tables.Count
For i = 1 To table_count
table_lie = ActiveDocument.Tables(i).Rows.Count
For j = 1 To table_lie
If InStr(ActiveDocument.Tables(i).Cell(1, j), str) > 0 Then
ActiveDocument.Tables(i).Cell(1, j).Select
Selection.Rows.Delete
With ActiveDocument.Tables(i)
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 110
End With
End If
Next
Next
End Sub
/**/
我是删除的所有表格中含有年度的那一行