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

Masta

New Member
Joined
Feb 22, 2022
Messages
33
Office Version
  1. 2021
  2. 2019
  3. 2016
Platform
  1. Windows
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.


 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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!
 
Upvote 0

Forum statistics

Threads
1,214,896
Messages
6,122,132
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top