ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Change UserForm ControlSource with VBA (https://www.excelbanter.com/excel-discussion-misc-queries/14732-change-userform-controlsource-vba.html)

[email protected]

Change UserForm ControlSource with VBA
 
Hi,

My desired scenario...

Private Sub Sale_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value here...
End Sub


Private Sub Delivery_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value to Something Else
here...
End Sub


The OptionButtons and Notes_TextBox are on a UserForm.

I want to be able to change what text is displayed in Notes_TextBox
(from named cells on various worksheets) by clicking on appropriate
Option Buttons on the UserForm.

Can I do this?

Thanks,
Jim


papou

Hello Jim
Very easily done if you use named ranges:
Private Sub Delivery_Notes_OptionButton_Click()
Me.Notes_TextBox.value = Range("Sale").Value
End Sub
Private Sub Delivery_Notes_OptionButton_Click()
Me.Notes_TextBox.Value = Range("Delivery").Value
End Sub

HTH
Cordially

a écrit dans le message de news:
...
Hi,

My desired scenario...

Private Sub Sale_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value here...
End Sub


Private Sub Delivery_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value to Something Else
here...
End Sub


The OptionButtons and Notes_TextBox are on a UserForm.

I want to be able to change what text is displayed in Notes_TextBox
(from named cells on various worksheets) by clicking on appropriate
Option Buttons on the UserForm.

Can I do this?

Thanks,
Jim




papou

Sorry juste realised I didn't read through all of your post
If these are option buttons then you may use something like:
Private Sub Delivery_Notes_OptionButton_Click()
If Delivery_Notes_optionButton Then
Me.Notes_TextBox.value = Range("Sale").Value
End If
End Sub
Private Sub Delivery_Notes_OptionButton_Click()
If Delivery_Notes_OptionButton Then
Me.Notes_TextBox.Value = Range("Delivery").Value
End If
End Sub

HTH
Cordially

"papou" a écrit dans le message de news:
...
Hello Jim
Very easily done if you use named ranges:
Private Sub Delivery_Notes_OptionButton_Click()
Me.Notes_TextBox.value = Range("Sale").Value
End Sub
Private Sub Delivery_Notes_OptionButton_Click()
Me.Notes_TextBox.Value = Range("Delivery").Value
End Sub

HTH
Cordially

a écrit dans le message de news:
...
Hi,

My desired scenario...

Private Sub Sale_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value here...
End Sub


Private Sub Delivery_Notes_OptionButton_Click()
Change Value of Notes_TextBox CONTROLSOURCE Value to Something Else
here...
End Sub


The OptionButtons and Notes_TextBox are on a UserForm.

I want to be able to change what text is displayed in Notes_TextBox
(from named cells on various worksheets) by clicking on appropriate
Option Buttons on the UserForm.

Can I do this?

Thanks,
Jim







All times are GMT +1. The time now is 03:07 AM.

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