Hide Row if "H" found

The Animal

Active Member
Joined
May 26, 2011
Messages
449
Hi.
I would like to create a toggle button that hides all rows if the letter "H" in found in the "A" column.

Any help with a formula that I can attach to a text box button would be great.

Thanks Stephen
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Put the following code in your ToggleButton. I guess it's a togglebutton ActiveX

Code:
Private Sub ToggleButton1_Click()
    
    Application.ScreenUpdating = False
    Cells.EntireRow.Hidden = False
    
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        If Cells(i, "A").Value = "H" Then
            Rows(i).EntireRow.Hidden = ActiveSheet.ToggleButton1
        End If
    Next
    
End Sub
 
Upvote 0
I do not understand, do you want the code for the togglebutton?
What do you want the textbox for?
 
Upvote 0
Hi.

I normally use a text box and just assign the formula to that text box that way I have control of all properties of the box. For example below may be applied to a text box to hide/unhide rows.

Sub ToggleCurrentMYOB()
ActiveSheet.Unprotect
Range("BF:BO").Columns.Hidden = Not Range("BF:BO").Columns.Hidden
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowFiltering:=True
End Sub

So was enquiring what formula would look like if I was doing above.
 
Upvote 0
text box? or commandbutton?

Could you upload an image of your sheet to the cloud for what you have and what do you call textbox?
 
Upvote 0
Hi

Cannot upload ATM

But yes Insert>Text Box, draw the Text Box and then assign or create the macro to the text box.

I just need a macro that hides and unhides the full rows if "H" is found in A4:A1500

Thanks
 
Upvote 0
Like this:

Code:
Private Sub TextBox1_GotFocus()
    Application.ScreenUpdating = False
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        If Cells(i, "A").Value = "H" Then
            Rows(i).EntireRow.Hidden = Not Rows(i).EntireRow.Hidden
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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