button,将一次隐藏和取消隐藏行。 类似于旋钮的东西

我已经search了很多问题,但找不到任何我想要做的答案。
我想隐藏和取消隐藏行。 我喜欢旋转button,你可以点击向上和向下箭头,但如果这不起作用,然后一个button隐藏和其他取消隐藏。

I have tried few VBA codes but none of them worked the way I want. **1st VBA code**: following code works to hide multiple rows but all at once not one at a time. If ToggleButton1.Value = True Then 'This area contains the things you want to happen 'when the toggle button is not depressed Rows(4).EntireRow.Hidden = True Rows(5).EntireRow.Hidden = True Rows(6).EntireRow.Hidden = True Else 'This area contains the things you want to happen 'when the toggle button is depressed Rows(4).EntireRow.Hidden = False Rows(5).EntireRow.Hidden = False Rows(6).EntireRow.Hidden = False End If 2nd VBA code: Hide and unhides just one row. If ToggleButton1.Value = True Then 'This area contains the things you want to happen 'when the toggle button is not depressed Rows(4).EntireRow.Hidden = True Else 'This area contains the things you want to happen 'when the toggle button is depressed Rows(4).EntireRow.Hidden = False End If Someone please help! 

SpinButton1是一个ActiveX旋钮,工作表(Min = 0,Max = 10或者你想显示/隐藏的行数)

A7这里将是显示/隐藏的行集合中的第一行

代码进入工作表模块。

 Private Sub SpinButton1_Change() Dim r As Long, mx As Long r = Me.SpinButton1.Value mx = Me.SpinButton1.Max With Me.Range("A7") If r > 0 Then .Resize(r).EntireRow.Hidden = False If r < mx Then .Offset(r, 0).Resize(mx - r).EntireRow.Hidden = True End With End Sub