ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   when select cell in range checkbox value is true_but how? (https://www.excelbanter.com/excel-programming/358838-when-select-cell-range-checkbox-value-true_but-how.html)

up2you

when select cell in range checkbox value is true_but how?
 

Hi all,

I have 3 checkbox in sheet and i have 3 range name x, y and z.

what i want is,

when i *select any cell in x range checkbox1.value=true *is run,
when i *select any cell in y range checkbox2.value=true *is run,
when i *select any cell in z range checkbox3.value=true * is run.

what is the code for this operations?

thanks.....


--
up2you
------------------------------------------------------------------------
up2you's Profile: http://www.excelforum.com/member.php...o&userid=33468
View this thread: http://www.excelforum.com/showthread...hreadid=532691


Ardus Petus

when select cell in range checkbox value is true_but how?
 
With your 3 ranges named "sel_X", "sel_Y" and "sel_Z",
paste following code in worksheet's code:

'-----------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
CheckBox1.Value = _
Not Intersect(Range("sel_X"), Target) Is Nothing
CheckBox2.Value = _
Not Intersect(Range("sel_Y"), Target) Is Nothing
CheckBox3.Value = _
Not Intersect(Range("sel_Z"), Target) Is Nothing
End Sub
'------------------

HTH
--
AP

"up2you" a écrit dans
le message de ...

Hi all,

I have 3 checkbox in sheet and i have 3 range name x, y and z.

what i want is,

when i *select any cell in x range checkbox1.value=true *is run,
when i *select any cell in y range checkbox2.value=true *is run,
when i *select any cell in z range checkbox3.value=true * is run.

what is the code for this operations?

thanks.....


--
up2you
------------------------------------------------------------------------
up2you's Profile:

http://www.excelforum.com/member.php...o&userid=33468
View this thread: http://www.excelforum.com/showthread...hreadid=532691




cm_gmail[_7_]

when select cell in range checkbox value is true_but how?
 

To snag a snippet of code from he
http://www.cpearson.com/excel/named.htm

You can do this:

Code:
--------------------
Function NameOfParentRange(Rng As Range) As String
Dim Nm As Name
For Each Nm In ThisWorkbook.Names
If Rng.Parent.Name = Nm.RefersToRange.Parent.Name Then
If Not Application.Intersect(Rng, Nm.RefersToRange) Is Nothing Then
NameOfParentRange = Nm.Name
Exit Function
End If
End If
Next Nm
NameOfParentRange = ""
End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells(1, 1).Value = NameOfParentRange(Target)
End Sub
--------------------


Change it to set the value of your checkboxes instead of the
cell(1,1)'s value.


--
cm_gmail
------------------------------------------------------------------------
cm_gmail's Profile: http://www.excelforum.com/member.php...o&userid=33451
View this thread: http://www.excelforum.com/showthread...hreadid=532691


cm_gmail[_8_]

when select cell in range checkbox value is true_but how?
 

To snag a snippet of code from he
http://www.cpearson.com/excel/named.htm

You can do this:

Code:
--------------------
Function NameOfParentRange(Rng As Range) As String
Dim Nm As Name
For Each Nm In ThisWorkbook.Names
If Rng.Parent.Name = Nm.RefersToRange.Parent.Name Then
If Not Application.Intersect(Rng, Nm.RefersToRange) Is Nothing Then
NameOfParentRange = Nm.Name
Exit Function
End If
End If
Next Nm
NameOfParentRange = ""
End Function

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells(1, 1).Value = NameOfParentRange(Target)
End Sub
--------------------


Change it to set the value of your checkboxes instead of the
cell(1,1)'s value.


--
cm_gmail
------------------------------------------------------------------------
cm_gmail's Profile: http://www.excelforum.com/member.php...o&userid=33451
View this thread: http://www.excelforum.com/showthread...hreadid=532691


up2you[_2_]

when select cell in range checkbox value is true_but how?
 

hi again all,
that's great. you are perfect consultants.

See all again...


--
up2you
------------------------------------------------------------------------
up2you's Profile: http://www.excelforum.com/member.php...o&userid=33468
View this thread: http://www.excelforum.com/showthread...hreadid=532691



All times are GMT +1. The time now is 02:05 PM.

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