ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change controlsource for textbox depending on combobox selection (https://www.excelbanter.com/excel-programming/433030-change-controlsource-textbox-depending-combobox-selection.html)

Maverikk

change controlsource for textbox depending on combobox selection
 
Hi, I have a userform with 3 cascading comboboxes, and a textbox. I need the
controlsource of the textbox to change depending upon the selection in
combobox3. I am looking for the code. I have in mind something like: If
combobox3.value = "wages" then textbox1.controlsource = sheet3, A1 etc. but
cant get it to work, also tried
If TextBox1.Value = w Then TextBox1.ControlSource =
Worksheets("main").Range("A1")
If TextBox1.Value = x Then TextBox1.ControlSource =
Worksheets("main").Range("b1")
Can anyone help please?



OssieMac

change controlsource for textbox depending on combobox selection
 
If ComboBox1.Value = "wages" Then
TextBox1.ControlSource = "Sheet3!A1"
End If

You enter it the same way you would enter it in the Properties dialog box
except enclose it in double quotes in the code.

--
Regards,

OssieMac


"Maverikk" wrote:

Hi, I have a userform with 3 cascading comboboxes, and a textbox. I need the
controlsource of the textbox to change depending upon the selection in
combobox3. I am looking for the code. I have in mind something like: If
combobox3.value = "wages" then textbox1.controlsource = sheet3, A1 etc. but
cant get it to work, also tried
If TextBox1.Value = w Then TextBox1.ControlSource =
Worksheets("main").Range("A1")
If TextBox1.Value = x Then TextBox1.ControlSource =
Worksheets("main").Range("b1")
Can anyone help please?



Maverikk

change controlsource for textbox depending on combobox selecti
 
Thanks Ossie Mac - really owe you one! Perfect.

"OssieMac" wrote:

If ComboBox1.Value = "wages" Then
TextBox1.ControlSource = "Sheet3!A1"
End If

You enter it the same way you would enter it in the Properties dialog box
except enclose it in double quotes in the code.

--
Regards,

OssieMac


"Maverikk" wrote:

Hi, I have a userform with 3 cascading comboboxes, and a textbox. I need the
controlsource of the textbox to change depending upon the selection in
combobox3. I am looking for the code. I have in mind something like: If
combobox3.value = "wages" then textbox1.controlsource = sheet3, A1 etc. but
cant get it to work, also tried
If TextBox1.Value = w Then TextBox1.ControlSource =
Worksheets("main").Range("A1")
If TextBox1.Value = x Then TextBox1.ControlSource =
Worksheets("main").Range("b1")
Can anyone help please?




All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com