ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   checkbox gets value not sets value (https://www.excelbanter.com/excel-discussion-misc-queries/123821-checkbox-gets-value-not-sets-value.html)

Marquel

checkbox gets value not sets value
 
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

Hank Scorpio

checkbox gets value not sets value
 
On Wed, 27 Dec 2006 13:46:01 -0800, Marquel
wrote:

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


---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *


All times are GMT +1. The time now is 12:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com