Check box macros

S

Sunlover

Hi there,

On a form if a checkbox is selected (TRUE) then I want the answer in A1 to
be $10.50. If not checked (FALSE) I want the answer in A1to be $2.50. How
do I do this?

Thanks in advance!
 
D

Dave Peterson

Use a linked cell with that checkbox.

And then you can use a formula that points at that linked cell:

=if(x222=true,10.50,2.50)

(x222 is my linked cell.)
 
R

Roger Converse

It would work something like this:

if checkbox1.value = true then
cell.(A1).value = $10.50
else
cell(A1).value = 2.50
end if

HTH
Thanks,
Roger
 
S

Sunlover

Hi Roger,

Thanks for the quick response. However, below is exactly what I entered,
but an error keeps popping up that says: Compile Error: Sub or Function not
defined1:

Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then
cell(A1).Value = 10.5
Else
cell(A1).Value = 2.5
End If

End Sub

Any suggestions?
 
D

Dave Peterson

Private Sub CheckBox1_Click()
If me.CheckBox1.Value = True Then
me.range("A1").Value = 10.5
Else
me.range("a1").Value = 2.5
End If
End Sub

I like to qualify the objects (both the checkbox and the range), but that wasn't
the real problem.

me.cells(1,1).value = 10.5

would have worked ok, too.
 
Top