+ Reply to Thread
Results 1 to 7 of 7

Using Checkboxes to enable/disable vb

  1. #1

    Using Checkboxes to enable/disable vb

    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


  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    I am not certain if this will help with your problem.

    But I created a blank **** 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.
    Google is your best friend!

  3. #3
    Dave Peterson
    Guest

    Re: Using Checkboxes to enable/disable vb

    Try removing the double quotes:

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



    [email protected] wrote:
    >
    > 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


    --

    Dave Peterson

  4. #4
    Paul
    Guest

    Re: Using Checkboxes to enable/disable vb

    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


  5. #5
    Dave Peterson
    Guest

    Re: Using Checkboxes to enable/disable vb

    Did removing the double quotes work when you tried it?


    Paul wrote:
    >
    > 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


    --

    Dave Peterson

  6. #6
    Paul
    Guest

    Re: Using Checkboxes to enable/disable vb

    Oddly enough it didn't

    Dave Peterson wrote:
    > Did removing the double quotes work when you tried it?
    >
    >
    > Paul wrote:
    > >
    > > 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

    >
    > --
    >
    > Dave Peterson



  7. #7
    Dave Peterson
    Guest

    Re: Using Checkboxes to enable/disable vb

    It worked ok for me when I tested.

    Paul wrote:
    >
    > Oddly enough it didn't
    >
    > Dave Peterson wrote:
    > > Did removing the double quotes work when you tried it?
    > >
    > >
    > > Paul wrote:
    > > >
    > > > 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

    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1