Text Box ControlSource issues

ultrawat

New Member
Joined
Nov 7, 2005
Messages
47
I have a spreadsheet which has pop-up user form, with text boxes which link to a cell on another sheet in the workbook.

ie the user form pops up, I enter a number in the text box field, and this number appears in the linked cell in a separate worksheet in the workbook.

My problem comes when I save the workbook to a different name. The ControlSource area in the properties fields keeps the cell reference for the 'old' filename.....??

Can anyone help with how this ControlSource link changes to the new file name??

Any help would be really appreciated..... :confused:
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I can reproduce that behaviour only if both workbooks are open and the original workbook is the ActiveWorkbook. Is that the case for you?

I tend to avoid the ControlSource property because it can be problematical. I update the Control in code when the UserForm is shown and the target cell when the value in the Control changes.
 

ultrawat

New Member
Joined
Nov 7, 2005
Messages
47
Thanks Andrew

I should have said that the process is Save as......

I like the idea of code instead of using ControlSource.

Can you give me a sample code for this process?

Really appreciate your help.....
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Sample code:

Code:
Private Sub UserForm_Initialize()
    TextBox1.Value = Worksheets("Sheet1").Range("A1").Value
End Sub

Private Sub TextBox1_Change()
    Worksheets("Sheet1").Range("A1").Value = TextBox1.Value
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,834
Messages
5,855,898
Members
431,772
Latest member
dannyboi1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top