Private Sub UserForm_Initialize()
TextBox1 = "I'm filled in"
TextBox2 = "I'm also filled in "
End Sub
Private Sub CommandButton1_Click() [COLOR="#008000"]' This runs when "Button1" is clicked[/COLOR]
TextBox1 = Range("A1")
TextBox2 = Range("A2")
End Sub
Private Sub CommandButton2_Click() [COLOR="#008000"]' This runs when "Button2" is clicked[/COLOR]
TextBox1 = Range("B1")
TextBox2 = Range("B2")
End Sub
There are a variety of event handling procedures. What you want is the Button_Click event.
Code:Private Sub CommandButton1_Click() [COLOR=#008000]' This runs when "Button1" is clicked[/COLOR] TextBox1 = Range("A1") TextBox2 = Range("A2") End Sub Private Sub CommandButton2_Click() [COLOR=#008000]' This runs when "Button2" is clicked[/COLOR] TextBox1 = Range("B1") TextBox2 = Range("B2") End Sub