a toggle button on a userform


Posted by Jim on December 15, 2001 4:43 PM

Hi,

I'm trying to use a toggle button to hide rows then
show rows it will hide or show but i haven't been able
to do both. Any help would be appreciated.
Thanks, Jim

Posted by Jacob on December 15, 2001 6:13 PM

Hi

This should get you started.

Sub test()

Dim MyRange

MyRange = InputBox("What range do you want hide?")
Range(MyRange).Select
Selection.EntireColumn.Hidden = True


End Sub

That will hide you inputted range, to unhide just change the code a bit. Attach the code to your userform buttons and you are set.

Jacob



Posted by Ivan F Moala on December 16, 2001 12:58 AM

Jim
Not sure if this is what you meant...

Private Sub ToggleButton1_Click()
If ToggleButton1.Value = False Then
Range("a1:f1").EntireColumn.Hidden = False
ToggleButton1.Caption = "Hide Columns"
Else
Range("a1:f1").EntireColumn.Hidden = True
ToggleButton1.Caption = "Show Columns"
End If
End Sub


It assumes your toggle button shows and hides
columns..change to rows for rows.
So when you click on it it should Hide/Show
depending on the state of the Togglebutton value
which is either true or false.


Ivan