Copy Multiple cells to multiple textboxes

sunjam

New Member
Joined
Feb 16, 2013
Messages
49
hello,

please help,

copy/paste every cells in every textboxes take us so much time.

When I copy 3 cells in a row, I need to paste it in 3 different textbox.

Is there a way that in just 1 paste, all copied cells will be pasted in three textboxes?

Sample scenario:

Range("A1:C1, A2:C2, A3:C3") manually copy (ctrl C)

Paste to (ctrl V)
Textbox1 Textbox2 Textbox3
A1 B1 C1
A2 B2 C2
A3 B3 C3

Textboxes are Multiline

or if not possible

a command that similar to copy paste serial number to different textboxes
sample format xxxx-xxxx-xxxx-xxxx

Thanks,
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Is the paste data in the workbook currently or an external source?

If its in the workbook you could just make the value of the text boxes equal the range needed.

Eg.
Code:
TextBox1.text = sheets("Sheet1").Range("A1").value
textbox2.text = sheets("Sheet1").Range("B1").value
...
The same for the other text boxes.

If coming from an external source or you just want to past into one text box, you may need to add an extra text box (Textbox5) to paste the entire data into.

I put this code into a text change event of the new text box (textbox5).

Code:
Private Sub Textbox5_Change()
Dim t As String
t = TextBox5.Text
TextBox1.Text = Split(t)(0) 'First Word
TextBox2.Text = Split(t)(1) 'Second Word
TextBox3.Text = Split(t)(2) 'Third Word
TextBox4.Text = Split(t)(3) 'Forth Word
End Sub

So if you pasted "This Will Split Data" into textbox5:
Textbox1 will return "This"
Textbox2 will return "Will"
Textbox3 will return "Split" and so on...

If your copying from another sheet to the textbox you will have tabs in your data so you'll need to change the small bit of code.

Code:
TextBox1.Text = Split(t, vbtab)(0) 'First Word

Just change for all textboxes and should work fine.

You might bump into some errors if you have more or less then 4 textboxes (with this code)

If you need it for more then 4 just add another textbox and in your code add the code to get the text (incrementally from 0)

Code:
...
TextBox4.Text = Split(t)(3) 'Forth Word
TextBox5.Text = Split(t)(4) 'Fifth Word
...

But give it a go and see how it goes
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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