|
楼主 |
发表于 2019-3-15 15:08
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
简化了一下代码,又有新问题
test2 - hide.rar
(22.64 KB, 下载次数: 1)
条件是 如果是FF2 或者FF1(因为是举例,实际代码不能用ff*简化) 然后下面的值含$
就折叠但是运行后FF1未折叠。
- If .Cells(6, nCol) = "Sum of FF2" Or .Cells(6, nCol + 1) = "Sum of FF1" And InStr(Range(Cells(7, nCol), Cells(y, nCol)).NumberFormatLocal, "$") Then
复制代码
完整代码如下。。。
- Sub Button2_Click()
- On Error Resume Next
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim nRow As Integer, nCol As Integer, nFillCol As Integer
-
- i = Cells(4, Columns.Count).End(1).Column
- y = Cells(Rows.Count, 1).End(3).Row
- With Sheet1
-
- For nCol = 2 To i
- If .Cells(6, nCol) = "Sum of FF2" Or .Cells(6, nCol + 1) = "Sum of FF1" And InStr(Range(Cells(7, nCol), Cells(y, nCol)).NumberFormatLocal, "$") Then
- For nRow = 7 To y
- Range(Columns(nCol), Columns(nCol)).Select
- Selection.Columns.Group
- Exit For
-
- Next
- End If
- Next
- End With
- ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|