![]() |
Linking Textbox and cell
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? |
Linking Textbox and cell
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? |
Linking Textbox and cell
Hi Phil,
one way I've been able to do that is to edit the code of the textbox and do Private Sub TextBox1_Change() sheets("TargetSheetName").range("A1").value=textbo x1.value End Sub "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? |
Linking Textbox and cell
woops - i guess i'm a little dislexic this morning - i did the reverse of
what you wanted. Looks like Toppers got it! J "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? |
Linking Textbox and cell
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? |
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? |
All times are GMT +1. The time now is 03:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com