I have a userform, within the userform there is a frame with 4 textbox, how would I pass the values of those 4 textbox into one cell? separated by comma or space.
I tried doing the following within my submit button.
Dim t As MSForms.Control
For Each t In Me.Frame1.Controls
If TypeOf t Is MSForms.TextBox Then
If IsEmpty(stCode1Box) Then
Exit For
End If
If stCode1Box Is Nothing Then
'Cells(emptyRow, 15).Value = stCode1Box.Value
ElseIf Not IsEmpty(stCode1Box) Then
Cells(emptyRow, 15).Value = stCode1Box.Value
ElseIf stCode2Box Is Nothing Then
'Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value
ElseIf Not IsEmpty(stCode2Box) Then
Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value
ElseIf stCode3Box Is Nothing Then
'Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value & ", " & stCode3Box.Value
ElseIf Not IsEmpty(stCode3Box) Then
Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value & ", " & stCode3Box.Value
ElseIf stCode4Box Is Nothing Then
'Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value & ", " & stCode3Box.Value & ", " & stCode4Box.Value
ElseIf Not IsEmpty(stCode4Box) Then
Cells(emptyRow, 15).Value = stCode1Box.Value & ", " & stCode2Box.Value & ", " & stCode3Box.Value & ", " & stCode4Box.Value
End If
End If
Next t
The result would pop up on that cell, and if more than one textbox had value, this would be separated by a ", " Comma.
Try simply
Cells(emptyRow, 15).Value = Cells(emptyRow, 15).Value & "," & stCode1Box.Value