Simple CHeck box to view/hide rows

G

Guest

I'm trying to create checkbox where if it's checked rows 6-9 show, if it's
unchecked they are hidden. I've go the follow, but I must be missing
something...

--------------------------


Private Sub Risk_Box()
Application.ScreenUpdating = False
If Risk_Box.Value = 0 Then
Range("A6:A9").EntireRow.Hidden = True
Else
If Risk_Box.Value <> 0 Then
Range("A6:A9").EntireRow.Hidden = False
End If
End If
Application.ScreenUpdating = True
End Sub
 
R

Ron de Bruin

Hi Shelly

If you use a checkbox from the controltoolbox then try this for a checkbox named "CheckBox1"
This is event code for thr sheetmodule

Private Sub CheckBox1_Click()
If CheckBox1.Value = False Then
Range("A6:A9").EntireRow.Hidden = True
Else
Range("A6:A9").EntireRow.Hidden = False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Hide Empty Rows When Printing 1
Print Selectd Rows 10
Unhide rows 1
Shorter code 13
Hiding Rows with Formulas 7
More Efficient code than this 14
Choose printout color or b/w using vba 2
hide rows with any dates 2

Top