Search code examples
excelvbatextboxuserform

VBA Combine values in 2 userform textboxes into a third textbox


I am having difficulty getting the value from textbox 1 and textbox 2 to combine and display in a textbox3 on a userform. Textbox1 and Textbox2 are locked, the values are dynamic and auto-filled from radio button controls. I have tried the following but it doesn't display the combined result in textbox3 and I think it's because the values in textbox 1 & 2 are the result of counter controls on the radio buttons. See image link.

Private Sub TextBox3_Change()
    textbox3.text=Textbox1.text & Textbox2.text
End Sub

enter image description here


Solution

  • I found that the code below works best, your values will be combined. I placed a space between the values for s&g's.

    Private Sub TextBox2_Change()
        Me.TextBox3.Value = Me.TextBox1.Value & " " + Me.TextBox2.Value
    End Sub