Change UserForm ControlSource with VBA

J

jim.excel

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
 
P

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
 
P

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
 
Top