Hello I'm trying add multiple lines of text to text box based off of values in ComboBox1 and 2. I get the text to show up when I make a selections on combobox1 but when an additional value on combobox2 is made it overwrites the text instead of add it to a new line. Below is the code, any assistance will be greatly appreciated.
Thanks,
VBA Code:
Private Sub ComboBox2_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Me.ComboBox2.Value = ws.Cells(i, "A") Then
Me.TextBox1 = vbNewLine & ws.Cells(i, "B").Value
Me.TextBox2 = vbNewLine & ws.Cells(i, "c").Value
End If
Next i
End Sub
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet2")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Me.ComboBox1.Value = ws.Cells(i, "A") Then
Me.TextBox1 = ws.Cells(i, "B").Value
Me.TextBox2 = ws.Cells(i, "c").Value
ElseIf Me.ComboBox1.Value = "" Then
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
End If
Next i
End Sub