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
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
I do not understand, do you want the code for the togglebutton?
What do you want the textbox for?
 

The Animal

Active Member
Joined
May 26, 2011
Messages
449

ADVERTISEMENT

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.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
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?
 

The Animal

Active Member
Joined
May 26, 2011
Messages
449

ADVERTISEMENT

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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,348
Messages
5,528,187
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top