A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I think the following is a cleaner code and easily scaleable for any number of textboxes.
Note: I used Option Base 1 to force the array having Lbound=1 , this way it matches the textbox index , but if you prefer working with zero base array then remove it and change the loop from 0 to 4.
Option Explicit
Option Base 1
Private Sub CommandButton1_Click()
Dim li As Long
Dim aTextBoxes()
Dim strConcatenate As String
aTextBoxes = Array(TextBox2, TextBox3, TextBox4, TextBox5, TextBox6)
strConcatenate = TextBox1.Text
For li = 1 To 5
If aTextBoxes(li) <> vbNullString Then
strConcatenate = strConcatenate & "," & aTextBoxes(li)
End If
Next
.Range("F" & lngNewRow).Value = strConcatenate
End Sub
Best regards, Harvey