永发信息网

如何用excel vba创建组并隐藏

答案:1  悬赏:20  手机版
解决时间 2021-01-22 17:03
  • 提问者网友:低吟詩仙的傷
  • 2021-01-22 05:49
如何用excel vba创建组并隐藏
最佳答案
  • 五星知识达人网友:雪起风沙痕
  • 2021-01-22 06:54
参考代码:
Sub Test()
Dim Sh As Worksheet
Dim Rng As Range
Dim Cell As Range
Dim First As Boolean
Dim FirstCell As Range
Dim LastCell As Range
Set Sh = Worksheets("Sheet1")
With Sh
Set Rng = .Range("B3:B" & .Range("B" & .Rows.Count).End(xlUp).Row)
End With
First = True
For Each Cell In Rng
If Left(Cell.Value, 3) <> "PRJ" Then
If First = True Then
Set FirstCell = Cell
Set LastCell = Cell
First = False
Else
Set LastCell = Cell
End If
Else
If First = False Then
First = True
Sh.Range(FirstCell, LastCell).Rows.Group
End If
End If
Next Cell
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯