Using Checkboxes to enable/disable vb

P

paul.salama

I'm running a macro and trying to have parts of the code run or not run
depending on whether various checkboxes are checked.

The checkboxes are from the Forms toolbar, and they all reference cells
in column L

Basically this is what I have..
If Sheet1.Cells(12, 7).Value = "TRUE" Then (I've tried of variations
of referencing the cell)
....code...

and just for good measure in the Else portion I've put
Sheet1.Range("E7") = [L7].Value

And of course L7 reads TRUE when I run the macro.


Thanks in advance

Paul Salama
 
B

Bearacade

I am not certain if this will help with your problem.

But I created a blank shit and a checkbox and put the following code in
it:

Sub test()
If CheckBox1.Value = "True" Then
MsgBox ("True")
Else
If CheckBox1.Value = "False" Then
MsgBox ("False")
End If
End If
End Sub

It also works if you are referencing a cell's value.
 
D

Dave Peterson

Try removing the double quotes:

If Sheet1.Cells(12, 7).Value = True Then



I'm running a macro and trying to have parts of the code run or not run
depending on whether various checkboxes are checked.

The checkboxes are from the Forms toolbar, and they all reference cells
in column L

Basically this is what I have..
If Sheet1.Cells(12, 7).Value = "TRUE" Then (I've tried of variations
of referencing the cell)
...code...

and just for good measure in the Else portion I've put
Sheet1.Range("E7") = [L7].Value

And of course L7 reads TRUE when I run the macro.

Thanks in advance

Paul Salama
 
P

Paul

Thanks a lot. it seems that the capitalization made a difference. so
matching on "True" worked, but not "TRUE"... Even though the actual
text is capitalized.

so this is what worked:
If Sheet1.[L7].Value = "True" Then
....code...

Thanks again.

Paul
 
D

Dave Peterson

Did removing the double quotes work when you tried it?

Thanks a lot. it seems that the capitalization made a difference. so
matching on "True" worked, but not "TRUE"... Even though the actual
text is capitalized.

so this is what worked:
If Sheet1.[L7].Value = "True" Then
...code...

Thanks again.

Paul
 
P

Paul

Oddly enough it didn't

Dave said:
Did removing the double quotes work when you tried it?

Thanks a lot. it seems that the capitalization made a difference. so
matching on "True" worked, but not "TRUE"... Even though the actual
text is capitalized.

so this is what worked:
If Sheet1.[L7].Value = "True" Then
...code...

Thanks again.

Paul
 
D

Dave Peterson

It worked ok for me when I tested.
Oddly enough it didn't

Dave said:
Did removing the double quotes work when you tried it?

Thanks a lot. it seems that the capitalization made a difference. so
matching on "True" worked, but not "TRUE"... Even though the actual
text is capitalized.

so this is what worked:
If Sheet1.[L7].Value = "True" Then
...code...

Thanks again.

Paul
 

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