Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel - Changing a value of a checkbox with VBA co (Excel 2000)

    I need to be able to click on a check box and have another check box change its value accordingly. How do I do this in Excel?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel - Changing a value of a checkbox with VBA co (Excel 2000)

    What kind of check boxes are you using? Those from the Forms toolbar or those from the Control Toolbox?

    <img src=/w3timages/blueline.gif width=33% height=2>

    If the check boxes were created using the Forms toolbar, right-click the first check box and select Assign Macro... from the popup menu. Specify a name and click New. Make the code look like this:

    Sub CheckBox1_Click()
    ActiveSheet.Shapes("Check Box 2").ControlFormat.Value = _
    ActiveSheet.Shapes("Check Box 1").ControlFormat.Value
    End Sub

    You can find out the actual name of a check box by right-clicking it, switching to the Visual Basic Editor, and typing

    ? Selection.Name

    in the Immediate window, followed by Enter.

    <img src=/w3timages/blueline.gif width=33% height=2>

    If the check boxes were created using the Control Toolbox, double-click the first check box and make the code look like this:

    Private Sub CheckBox1_Click()
    Me.CheckBox2 = Me.CheckBox1
    End Sub

    You can find out the actual name of a check box by selecting it (in design mode) and looking at (Name) property in the Properties window.

Posting Permissions

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