欢迎光临散文网 会员登陆 & 注册

vba Word表格批量删除含有某一字符的指定行

2021-01-28 15:48 作者:北阪有桑123  | 我要投稿

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


/**/

我是删除的所有表格中含有年度的那一行

vba Word表格批量删除含有某一字符的指定行的评论 (共 条)

分享到微博请遵守国家法律