r0bism123

Board Regular
Joined
Feb 8, 2018
Messages
57
Hi gang,

I need some help. I want to unhide the below range without having the "Yes" criteria. So, when I press my Toggle Button, the action unhides all rows without criteria for all of the sheets in the workbook. I have been playing with the code and I can't figure it out. Your help is appreciated!

HTML:
Sub Unhide_All_Rows()
 Dim c As Range
 Dim ws As Worksheet
 Dim cR As Range

Set cR = Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
 
For Each ws In ThisWorkbook.Worksheets
    With ws
        Set cR = .Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")
        For Each c In cR
            If c.Value = "Yes" Then c.EntireRow.Hidden = False
        Next c
    End With
Next ws
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 
In post #5 you said:
I am unfamiliar with the toggelButton_Click Event.

And two of us have said Why do you want to use a Toggle Button?

A Toggle Button is like a light switch.

The light is on or the light is off.

So in your case it would be like this:
If the row is hidden then unhide it
If the row is unhid then hide it.

But you have a addition need if the cell says yes do something if not do not do something.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
In post #5 you said:
I am unfamiliar with the toggelButton_Click Event.

And two of us have said Why do you want to use a Toggle Button?

A Toggle Button is like a light switch.

The light is on or the light is off.

So in your case it would be like this:
If the row is hidden then unhide it
If the row is unhid then hide it.

But you have a addition need if the cell says yes do something if not do not do something.




Yes, that is how it is used. I misunderstood what he was asking. Here is the toggle code I as using:

Code:
Private Sub ToggleButton9_Click()     If ToggleButton9.Value Then
        Call Module9.Hide_Rows_Containing_Value_All_Sheets
        ToggleButton9.Caption = "Unhide Rows"
    Else
        ToggleButton9.Caption = "Hide Rows"
        Call Module9.Unhide_All_Rows
    End If
End Sub
Module 9 code is as follows:

Code:
Sub Hide_Rows_Containing_Value_All_Sheets()  
 Dim c As Range
 Dim ws As Worksheet
 Dim cR As Range

Set cR = Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
 
For Each ws In ThisWorkbook.Worksheets
    With ws
        Set cR = .Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")
        For Each c In cR
            If c.Value = "Yes" Then c.EntireRow.Hidden = True
        Next c
    End With
Next ws
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Sub Unhide_All_Rows()
 Dim c As Range
 Dim ws As Worksheet
 Dim cR As Range

Set cR = Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
 
For Each ws In ThisWorkbook.Worksheets
    With ws
        Set cR = .Range("DF8:DF12,DF19:DF28,DF35:DF209,DF244:DF252,DF259,DF261")
        For Each c In cR
            If c.Value = "Yes" Then c.EntireRow.Hidden = False
        Next c
    End With
Next ws
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 
Upvote 0
I figured it out. I just added another if statement to meet the other criteria of "No" and it works as I wanted.
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,454
Members
448,898
Latest member
drewmorgan128

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