PDA

View Full Version : [SOLVED:] Check Box



mgonzalez07
08-21-2005, 05:45 PM
Hi, I am making a worksheet that includes 4 Form Check Boxes. I want to write a macro so that when Check Box 1 is checked a formula is put in a specific cell and then the formula is copied down about 20 rows. If Check Box 2 is checked a different forumula is put in the cell and copied down and the same idea goes for Box 3 and 4. Can someone please help?

Jacob Hilderbrand
08-21-2005, 05:48 PM
Change the Forms CheckBoxes to ActiveX CheckBoxes, then try this code for each one.



Option Explicit

Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Range("A1").Value = "=B1"
Range("A1").AutoFill Destination:=Range("A1:A20")
End If
End Sub

lucas
08-21-2005, 07:23 PM
Hi Jake,

How could you control the users ability to only select one of the four checkboxes, since there is no group box for activeX checkboxes. attachment

Jacob Hilderbrand
08-21-2005, 07:25 PM
I would use OptionButtons.

Otherwise the last CheckBox clicked True would take effect. But if each CheckBox refers to a different range, it may not matter.

lucas
08-21-2005, 07:34 PM
Thats terrific Jake,

works great with optionbuttons in case you are using the same range for the formula's...thanks

mgonzalez07
08-22-2005, 07:51 PM
The code works great, thanks for the help.

Jacob Hilderbrand
08-22-2005, 07:57 PM
You're Welcome :beerchug:

Take Care