Toggle Button VBA- hides correct rows, unhides extras?

NikkiBlast

New Member
Joined
Aug 21, 2019
Messages
2
I'm working on a sheet that has multiple tables of data. One tracks budget and one tracks labor hours. In the labor Hours table, I created a toggle button that will hide rows containing employees who have contributed zero hours towards a project. It was working GREAT, but I had to make some tweaks to the table, and now when you click the button, it hides the rows correctly (using helper column "X"). However when you click it again to unhide them, it also unhides rows 34-45, despite their being outside the range I set (rows 48-72). I have examined this thing up and down and can't figure out why it is happening. Can someone check out my code below and see if they have any suggestions? My remaining sanity thanks you.

PHP:
Private Sub ToggleButton1_Click()

Set WS = Worksheets("Master")
Col = "X"
UpR = 72
LowR = 48

If ToggleButton1.Value = True Then
    With WS
        For FR = UpR To LowR Step -1
            If .Range(Col & FR) = 0 Then
                .Rows(FR).Hidden = True
            End If
        Next FR
    End With
End If

If ToggleButton1.Value = False Then
    WS.Rows.EntireRow.Hidden = False
End If

End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi & welcome to MrExcel.
Try
Code:
<code><code>[COLOR=#000000][COLOR=#0000BB] [/COLOR][/COLOR]WS.Rows("48:72").Hidden = False[COLOR=#000000][/COLOR]</code></code>
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,411
Messages
6,119,346
Members
448,888
Latest member
Arle8907

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