|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 根据关键词分级显示()
- Dim St$
- ActiveSheet.Cells.ClearOutline
- ActiveSheet.Outline.SummaryRow = xlAbove
- s0 = 5
- s1 = Cells(Rows.Count, 1).End(xlUp).Row
- VbaSpeed False
- j = 4
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- Range(Cells(s0 + 1, j), Cells(s1, j)).Rows.Group
- For i = s0 + 1 To s1
- St = Cells(i, j)
- If St = "事项" Then
- UnGroupAt i, j, 6
- ElseIf St = "分部" Then
- UnGroupAt i, j, 5
- ElseIf St <> "" Then
- UnGroupAt i, j, 4
- End If
- Next i
- j = 5
- For i = s0 + 1 To s1
- St = Cells(i, j)
- If St = "事项" Then
- UnGroupAt i, j, 3
- ElseIf St = "小计" Then
- UnGroupAt i, j, 2
- ElseIf St = "分计" Then
- UnGroupAt i, j, 1
- End If
- Next i
- VbaSpeed True
- End Sub
- Sub UnGroupAt(ByVal i&, ByVal j&, ByVal k&)
- For l = 1 To k
- Cells(i, j).EntireRow.Ungroup
- Next l
- End Sub
复制代码 |
|