+ Reply to Thread
Results 1 to 4 of 4

Marking Checkbox from VBA

  1. #1
    konpego
    Guest

    Marking Checkbox from VBA

    Hello,

    I have a range of cells ("B20:L20") all containing a checkbox. These
    can be checked/un-checked from excel and then evaluated in VBA code.
    But I would like to check/un-check them from inside the VBA code...

    Is it possible to check/un-check a checkbox from VBA code?

    /konpego

  2. #2
    Bob Phillips
    Guest

    Re: Marking Checkbox from VBA

    If it is a forms checkbox, then

    activesheet.checkboxes("Check Box 1").Value = false (or True)

    If it is a controls toolbox checkbox, then

    activesheet.oleobjects("CheckBox1").object.value=false (or True)

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "konpego" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I have a range of cells ("B20:L20") all containing a checkbox. These
    > can be checked/un-checked from excel and then evaluated in VBA code.
    > But I would like to check/un-check them from inside the VBA code...
    >
    > Is it possible to check/un-check a checkbox from VBA code?
    >
    > /konpego




  3. #3
    Neil
    Guest

    RE: Marking Checkbox from VBA

    Assuming your CheckBox is called CheckBox1, use

    Checkbox1 = True
    Checkbox1 = False

    To change the status if the CheckBox.

    Of course if your checkboxes are different names, then substitute those for
    Checkbox1!


    Neil


    www.nwarwick.co.uk


    "konpego" wrote:

    > Hello,
    >
    > I have a range of cells ("B20:L20") all containing a checkbox. These
    > can be checked/un-checked from excel and then evaluated in VBA code.
    > But I would like to check/un-check them from inside the VBA code...
    >
    > Is it possible to check/un-check a checkbox from VBA code?
    >
    > /konpego


  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello konpego,

    It can and it is easy to do. To use this code, you will need to supply 2 things - the name of the Worksheet the Checkbox is on and the name of the CheckBox. Here I have used CheckBox1 on the Worksheet named "Sheet1" (the default name).
    _________________________________________________________________

    Example to Check CheckBox1:

    Worksheets("Sheet1").OLEObjects("CheckBox1").Object.Value = True

    Example to Clear CheckBox1:

    Worksheets("Sheet1").OLEObjects("CheckBox1").Object.Value = False
    _________________________________________________________________

    Hope this helps,
    Leith Ross

+ 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