I'm still having problems with my macros that need to toggle off a check box.

M

Marc

Someone gave me this macro:

Private Sub CheckBox1_Click()
Range("A1").Select 'Active Cell Select
If CheckBox1.Value = True Then
Selection.EntireRow.Hidden = True
Else: CheckBox1.Value = False
Selection.EntireRow.Hidden = False
End If
End Sub

When I run it as is I get an error in the third line "If CheckBox1.Value =
True Then" "Run time '424': Object required". I change the name of the
check box back to from CheckBox1 but even when I changed it back I still get
the same error message. What is the purpose of the "Range("A1").Select "?
Is it the range of the cells that are to be hidden? I realize these are
very basic of questions. I need to have a macro that hides and unhides
columns and rows that are spread over several worksheets and several
worksheets themselves. I have renamed the checkboxes to correspond to the
task that they are doing i.e.cbxSelAudioHideUnhide. For the line
"Selection.EntireRow.Hidden = True" I have used:

Sheets(Sheet03).Select
Rows("11:34").Select
Selection.EntireRow.Hidden = True
Sheets(Sheet04).Select
Rows("10:28").Select
Selection.EntireRow.Hidden = True
Sheets(Sheet09).Select
Rows("12:35").Select
Selection.EntireRow.Hidden = True

and changed them to the corresponding trues or falses. What do I use for
the range statement?

I do appreciate all your help.

Marc
 
F

flummi

As I see it you don't need the "Range("A1").Select " statement.

It only seems to be there because the statement
"Selection.EntireRow.Hidden = True" needs a SELECTION.

Does the amended code work as you require?

I assume your checkbox is part of a userform. Did you place the code
into the Private Sub CheckBox1_Click() event (right click on the
checkbox on the userform and select "view code")?

I tried it here and it does exactly what is should do without any
error.

Regards

Hans
 
M

Marc

So I would make the rows, columns, and sheets the Selection statement?

No the checkbox is not part of a form part of the worksheet for what I'm
doing it sees to be less confusioning.

Yes I can get it to work but I need it to hide the rows and column that are
on different worksheets along with individual work sheets.What I'm trying to
accomplish is that when there is a chewck in the check box rows 5-16 on
sheets #2 are unhidden, columns D - H are unhidden on worksheet #4 and
worksheets #7, 8 11 and 15 are unhidden when you unclick the box they all
become hidden. If that helps.

Marc
 

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

Top