|
楼主 |
发表于 2013-4-23 09:51
|
显示全部楼层
dufu021 发表于 2013-4-23 08:29
建议你A列采用:
如下是我编写的 最新版 代码,目前功能是 奇次触发A表单元格 隐显判断,偶次触发 整体恢复。
缺陷1: 不能 在 判断 A1 是否 更改值 后, 触发功能
缺陷2: 还是之前的速度慢的问题: 如何记录 被隐藏的行的 行号,并与更改值 的行 进行比较 ?- Public k
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Count <> 1 Then Exit Sub
- If Target.Column <> 1 Then Exit Sub
- If Target.Row <> 1 Then Exit Sub
- Call 隐显恢复
- End Sub
- Sub 隐显恢复()
- k = k + 1
- If k > 10 Then
- k = 1
- Call 行列隐藏显示
- Else
- If k Mod 2 = 1 Then
- Call 行列隐藏显示
- Else
- Call 恢复初始
- End If
- End If
- End Sub
- Sub 行列隐藏显示()
- Dim i As Integer
- Dim j As Integer
- For i = 2 To 21
- If Cells(i, 1).Value = "" Then
- Cells(i, 1).EntireRow.Hidden = True
- Else
- Cells(i, 1).EntireRow.Hidden = False
- End If
- Next i
- For j = 3 To 7
- If Cells(1, j).Value = "" Then
- Cells(1, j).EntireColumn.Hidden = True
- Else
- Cells(1, j).EntireColumn.Hidden = False
- End If
- Next j
- End Sub
- Sub 恢复初始()
- Dim i As Integer
- Dim j As Integer
- For i = 3 To 7
- Cells(1, i).Select
- Selection.EntireColumn.Hidden = False
- Next i
- For j = 2 To 21
- Cells(j, 1).Select
- Selection.EntireRow.Hidden = False
- Next j
- End Sub
- Public arr(1 To 1, 1 To 1)
- Sub 集成功能()
- End Sub
复制代码 |
|