checkbox gets value not sets value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think that I could get a checkbox to go out and do something after someone
checked it - But can I set the value of a checkbox based on the value in
some cell?

Example - I have a checkbox cleverly known as Checkbox 15;
I would like that checkbox to set itself to being checked when my user
places a value in the cell F26

doable? and how?

Users could set this checkbox themselves but always forget....thanks ahead
of time
 
I think that I could get a checkbox to go out and do something after someone
checked it - But can I set the value of a checkbox based on the value in
some cell?

Example - I have a checkbox cleverly known as Checkbox 15;
I would like that checkbox to set itself to being checked when my user
places a value in the cell F26

doable? and how?

Users could set this checkbox themselves but always forget....thanks ahead
of time

Assuming that you're using the checkbox from the Control Toolbox
toolbar rather than the Forms toolbar, you can do it by using the
worksheet change event as follows (right click on the sheet tab and
select "View Code", then copy and paste this procedure into the module
that appears):

Private Sub Worksheet_Change(ByVal Target As Range)

Dim vnt As Variant

If Target.Address = "$F$26" Then

vnt = ""
'Just in case something weird happens in reading the value
On Error Resume Next
vnt = CStr(Target.Value)
On Error GoTo 0

If vnt = "" Then
Me.CheckBox15.Value = False
Else
Me.CheckBox15.Value = True
End If

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top