?
Solved

Excel VBA Checkbox action

Posted on 2015-01-27
5
Medium Priority
?
100 Views
Last Modified: 2015-02-19
I have a checkbox that when checked I need cells A10:H13 to be visible, and when the checkbox is not checked I need A10:H13 to be hidden.
0
Comment
Question by:macone1976
5 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40573489
By hidden do you mean

entire rows hidden
entire columns hidden
entire rows and columns hidden
or just the text hidden with the cells visible?
0
 

Author Comment

by:macone1976
ID: 40573507
entrie rows hidden
0
 

Expert Comment

by:EISTO
ID: 40573518
3 specific rows, or will the row numbers change depending on the content in the spreadsheet?
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 40573543
You can use this macro as shown in the attached file

Private Sub CheckBox1_Change()
    If CheckBox1 Then
        Range("A10:H13").EntireRow.Hidden = True
    Else
        Range("A10:H13").EntireRow.Hidden = False
    End If
End Sub
Hiddenrowswithcheckbox.xls
0
 
LVL 34

Expert Comment

by:Rob Henson
ID: 40575062
Does it have to a check box? You can do this without VBA.

Select the three rows and go to the Data Menu and choose Group > Rows.

This will put a button in the left hand margin, next to either row 9 or 14 depending on settings, and will enable the hiding or unhiding of those rows. When hidden the button will show a + sign, when unhidden the button will show a - sign and the rows affected will have a little bullet next to them.

Thanks
Rob H
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question