none
Excel Controls (Button, CheckBoxes) RRS feed

  • Question

  • Hi

    I have a Excel Sheet with 3 CheckBoxes and 1 Button. Then I have created a makro to handle the Button clicks.
    I want to read if the checkboxes are selected or not and then I want to write a text into the active cell.

    My problem is, that I don't know how I can use the checkboxes in this makro.
    Can somebody help me?

    Wednesday, July 6, 2011 10:12 AM

Answers

  • Hi blue1988,

    no code available?

    Try this:

    If Checkbox1.value = true then
      msgbox "Check box 1 Checked"
    End if
    If Checkbox2.value = true then
      msgbox "Check box 2 Checked"
    End if
    '...
    

     


    Please 'Mark as Answer' if I helped. This helps others who have the same problem!
    • Marked as answer by blue1988 Wednesday, July 6, 2011 12:08 PM
    Wednesday, July 6, 2011 10:27 AM

All replies

  • Hi blue1988,

    no code available?

    Try this:

    If Checkbox1.value = true then
      msgbox "Check box 1 Checked"
    End if
    If Checkbox2.value = true then
      msgbox "Check box 2 Checked"
    End if
    '...
    

     


    Please 'Mark as Answer' if I helped. This helps others who have the same problem!
    • Marked as answer by blue1988 Wednesday, July 6, 2011 12:08 PM
    Wednesday, July 6, 2011 10:27 AM
  • If your checkboxes are Forms type -

    Dim ticked As Long
    ticked = ActiveSheet.Shapes("Check box 1").ControlFormat

    Select Case ticked
    Case xlOff: ' code not ticked
    Case xlOn: ' code ticked
    Case xlMixed: ' unusual
    End select

    If ActiveX type you can do as suggested by Dennis if 100% sure the control exists on the sheet, otherwise (to avoid compile error and instead trapable error)

    Dim bTick as Boolean
    bTick  = ActiveSheet.OLEObjects("CheckBox1").Object.Value

    Peter Thornton

    Wednesday, July 6, 2011 12:03 PM
    Moderator
  • Hi

    Thank you it works.

    MFG

    Wednesday, July 6, 2011 12:08 PM