View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default How to know the linked cell of a check box

Hi Maurizio,

Sub test()
Dim LinkCellAddr As string
Dim CheckboxRow As Long, LinkedCellRow As Long
Dim cbx As CheckBox

Set cbx = ActiveSheet.CheckBoxes(Application.Caller)
'On Error GoTo errH

CheckboxRow = cbx.TopLeftCell.Row

s = "CheckboxRow " & CheckboxRow & vbCr & "LinkedCellRow "

LinkCellAddr = cbx.LinkedCell

If Len(LinkCellAddr) Then
LinkedCellRow = Range(LinkCellAddr).Row
s = s & LinkedCellRow
Else
s = s & " no linked cell"
End If

MsgBox s

errH:
End Sub

Above assumes macro assigned to a Forms Checkbox. If your Checkbox is an
ActiveX control form the Controls toolbox you can use almost same code

Private Sub CheckBox1_Click()
Dim cbx As Object

Set cbx = CheckBox1

' code as in test above

End Sub

Regards,
Peter T

"gm139" wrote in
message ...

I have created in my sheet a check box with a linked cell to it.

When I click on this control a macro is activated.

I would like to know how is possible to know the value of the linked
cell.

The purpose of this is to know the row where the check box is
positioned, since the linked cell is on the same row of the control.

Thanks.
Maurizio


--
gm139
------------------------------------------------------------------------
gm139's Profile:

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