# Copy, paste and split problem, need simple solution please.



## Masta (Aug 11, 2022)

I have TextBox1, TextBox2, TextBox3, TextBox4 and i have 

Private Sub CommandButton1_Click()
TextBox5.Paste
   If TextBox5.Value <> "" Then
    With New MSForms.DataObject
      .SetText TextBox5.Text
      .PutInClipboard
    End With

End If

End Sub

When i paste this data  1181117    9401670    GR1326GN 11.08.2022 to TextBox5 i need to split them in tha way TextBox1 1181117, TextBox2  9401670, TextBox3 GR1326GN and TextBox4 11.08.2022 . I have bunch load of this data in other program base so i need to select and copy data from there than i need to click on Private Sub CommandButton1_Click() to paste data, and after that data needed to be splited in TextBoxes. Thanks.


----------



## Masta (Dec 18, 2022)

Private Sub CommandButton1_Click()
    TextBox5.Paste
    If TextBox5.Value <> "" Then
        With New MSForms.DataObject
            .SetText TextBox5.Text
            .PutInClipboard
        End With

        ' Split the data into an array using the space character as the delimiter
        Dim dataArray As Variant
        dataArray = Split(TextBox5.Text, " ")

        ' Assign the values from the array to the text boxes
        TextBox1.Text = dataArray(0)
        TextBox2.Text = dataArray(1)
        TextBox3.Text = dataArray(2)
        TextBox4.Text = dataArray(3)
    End If
End Sub

My solution if someone need it!


----------

