View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Linking Textbox and cell

Phil,
Your code worked for me - I merged cells M7 & M8. Run this line of
code before you test to ensure the Worksheet _Change will kick-off.:

Sub X()
Application.EnableEvents=True
end Sub


And I defined the Textbox using the Control toolbox.

HTH

"Phil Hageman" wrote:

Hi Toppers,

Thanks for your reply.

Put the code in worksheet "C1" where the text-entry cell is a merged cell,
M7. The target Textbox is "Textbox1" in worksheet named "Strategy Map".

When typing text in M7, nothing changes in the Textbox. Is the merged cell
the problem? No error messages. I need this to work any time the user makes
an entry in M7.

Here is how I modified the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Errorhandler
If Target.Address = "$M$7" Then
Application.EnableEvents = False
Worksheets("Strategy Map").TextBox1.Value = Target.Value
End If
Errorhandler:
Application.EnableEvents = True
End Sub

Thanks, Phil


"Toppers" wrote:

Hi,

This assumes entry cell (A1) is in Sheet2 and textbox on Sheet1. Change
these as required

Add this code to Sheet2 by right clicking on sheet tab and selecting "view
code".

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Errorhandler
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Worksheets("Sheet1").TextBox1.Value = Target.Value
End If
Errorhandler:
Application.EnableEvents = True
End Sub


HTH


"Phil Hageman" wrote:

Is there a way to link a Textbox in one worksheet to a cell in another
worksheet, such that text entered in the cell automatically appears in the
Textbox?