Converting from active x to form controls

edwardzbrown

New Member
Joined
Jun 12, 2017
Messages
20
Hello, I have an axtive X toggle button that works pretty slick. It shows and hides a range of rows by use of hidden "addresses" - basically a cell with a range it looks for.

HTML:
Private Sub ToggleButton1_Click()
Dim xAddress As String
rw1 = ActiveWorkbook.ActiveSheet.Columns(1).Find(99991).Rowrw2 = ActiveWorkbook.ActiveSheet.Columns(1).Find(99992).Row
xAddress = rw1 & ":" & rw2
If ToggleButton1.Value Then    Application.ActiveSheet.Rows(xAddress).Hidden = False    ToggleButton1.Caption = "Hide"Else    Application.ActiveSheet.Rows(xAddress).Hidden = True    ToggleButton1.Caption = "Show"End If
End Sub

But now I want to simply use a show/hide form button that works similar to another form control I use:

HTML:
Sub HideButton_Click()'Show and Hide The Heading Bar
    With Rows("2:3")Rows("2:3").EntireRow.Hidden = Not Rows("2:3").EntireRow.HiddenEnd With
End Sub

How do I change the code to do the show hide without the toggle button IF function? I want to use the same WITH command from the form control button but with the row finding "address" function I used before. Is that possible?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Is this what you're after
Code:
Private Sub HideButton_Click()
Dim rw1 As Long, rw2 As Long
rw1 = Columns(1).Find(99991).Row
rw2 = Columns(1).Find(99992).Row
Rows(rw1 & ":" & rw2).Hidden = Not Rows(rw1 & ":" & rw2).Hidden
End Sub
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top