Solved

Hide cells

Posted on 2014-12-23
5
109 Views
Last Modified: 2014-12-23
I have a checkbox on an excel sheet.  when checked, I need to hide cells A34:H54, when unchecked make the cells visible.
0
Comment
Question by:macone1976
  • 2
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 40515589
What sort of Checkbox are you using? Forms or ActiveX?
0
 

Author Comment

by:macone1976
ID: 40515621
Forms
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 40515642
Assign this Macro to the Checkbox....

Sub CheckBox1_Click()
    
    Range("A34:H54").EntireRow.Hidden = (ActiveSheet.Shapes("Check Box 1").ControlFormat.Value = 1)
    
End Sub

Open in new window


...where "Check Box 1" is the name of your Checkbox. Note that you can't hide individual cells, only entire rows or columns. If you wanted to hide columns A:H, change EntireRow to EntireColumn.
0
 

Author Closing Comment

by:macone1976
ID: 40515755
Thanks, it works...
0
 
LVL 2

Expert Comment

by:Rossano Praderi
ID: 40515772
The follow code can be an alternative solution...

Private Sub CheckBox1_Click()
  If CheckBox1.Value Then
    Hide
  Else
    UnHide
  End If
End Sub
Sub Hide()
    With Range("A34:H54").Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
    End With
End Sub
Sub UnHide()
    With Range("A34:H54").Font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
End Sub

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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 …

776 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