PDA

View Full Version : Solved: hyperlink a cell to a textbox



shunz
05-10-2012, 10:51 PM
hi,

i want to create a hyperlink between a cell and a textbox in such a way that when i click on the cell/cell value, the textbox is selected and highlighted.

havent been able to do it yet. would really appreciate if someone can help.

mancubus
05-11-2012, 01:28 AM
hi and wellvcome to the forum.

you may try one of the following worksheet events. change cell's address and control's name if necessary.


click

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
TextBox1.Activate 'Activex control
End Sub




double click

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address <> "$A$1" Then Exit Sub
Cancel = True
TextBox1.Activate 'Activex control
End Sub

shunz
05-11-2012, 02:59 AM
thank you mancubus.

i have already inserted the textboxes manually. so when i tried using your code, it didn't recognise "textbox1" . how do i identify the textbox ID/number? or more precisely, how do i make the code recognise those textboxes?

PS: i do not want to insert the textbox through activex control

mancubus
05-11-2012, 06:23 AM
you're wellcome.
click on the control in design mode and check addres bar (topleft corner)

http://vbadud.blogspot.com/2008/07/linking-text-box-to-excel-range-using.html

shunz
05-11-2012, 07:43 AM
that works now. wasn't aware of inserting textboxes through developer tab. thanks again :)

mancubus
05-11-2012, 10:11 AM
you're wellcome.

pls mark the thread as solved from thread tools (top right corner of the first post.)