|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 删除合计空表()
- Dim FindRng As Range
- Dim i%, rStart&, rEnd&, Text$
- With ActiveDocument
- i = 1
- Do Until i > .Tables.Count
- With .Tables(i)
- rStart = .Cell(.Rows.Count, 1).Range.Start
- rEnd = .Cell(.Rows.Count, .Columns.Count).Range.End
- Text = ActiveDocument.Range(rStart, rEnd)
- Text = Replace(Replace(Replace(Text, " ", ""), Chr(13), ""), Chr(7), "")
- If Text = "合计" Then
- Set FindRng = ActiveDocument.Range(0, .Range.Start)
- With FindRng.Find
- .ClearFormatting
- .ParagraphFormat.OutlineLevel = wdOutlineLevel3
- .Format = True
- .Wrap = wdFindStop
- .Forward = False
- rStart = IIf(.Execute, FindRng.Start, 0)
- End With
- Set FindRng = ActiveDocument.Range(.Range.End, ActiveDocument.Content.End)
- With FindRng.Find
- .ClearFormatting
- .ParagraphFormat.OutlineLevel = wdOutlineLevel3
- .Format = True
- .Wrap = wdFindStop
- .Forward = True
- rEnd = IIf(.Execute, FindRng.Start, ActiveDocument.Content.End)
- End With
- 'Debug.Print ActiveDocument.Range(rStart, rEnd)
- ActiveDocument.Range(rStart, rEnd).Delete
- Else
- i = i + 1
- End If
- End With
- Loop
- End With
- Set FindRng = Nothing
- End Sub
复制代码
- Sub 删除表格空行()
- '
- '删除表格中除了第一列之外都是空白单元格的行
- '
- Dim i%, iRow%, iCol%, rStart&, rEnd&, Text$
- If Selection.Tables.Count = 0 Then
- MsgBox "没有指定表格"
- Else
- With Selection.Tables(1)
- iRow = .Rows.Count
- iCol = .Columns.Count
- For i = iRow To 2 Step -1 '跳过表头第一行
- rStart = .Cell(i, 2).Range.Start
- rEnd = .Cell(i, iCol).Range.End
- Text = ActiveDocument.Range(rStart, rEnd)
- Text = Trim(Replace(Replace(Text, Chr(13), ""), Chr(7), ""))
- If Len(Text) = 0 Then
- .Cell(i, 2).Select
- With Selection
- .SelectRow: .Rows.Delete
- End With
- End If
- Next i
- End With
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|