clipboard to columns

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
201
Hello,

Could someone let me know if data from clipboard can be copied to different columns.

Version used Excel 2010

For Example - Clipboard allows to copy 24 items.

Data in clipboard will be as

304601-520
GA
Statesboro
Box 8101
Carol Builing
Georgia Southern University

So from bottom down,in the clipboard the data must be pasted in excel starting from first column, second columns, then and so on.
In excel
Row 1 - Col 1(Georgia Southern University ) Col 2(Carol Builing ) and col 3 (Box 8101) so

To Note -
1) the Number of data in clipboard can vary from 5-24 items and there by the columns to be filled based on the data availability
2) After the data is pasted in excel from clipboard, the clipboard content must be cleared
3) Could the complete event from clipboard to excel be done wit a command buttom

So each time the data is pasted that will be a new record, the next set of data in the clipboard becomes the next record. So this will be filled in second row.

Any help is greatly appreciated, and can save immense manual work and physical strain


Thanks in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
ok here is some code that I use to copy from a pdf and paste into excel 5 rows by 4 columns

Code:
Sub DoNSRA2()
Dim myData As DataObject

Set myData = New DataObject
myData.GetFromClipboard
strnsra = myData.GetText

s = Split(strnsra, vbCrLf)
u = UBound(s)
For j = 0 To 4
    For k = 0 To 3
        p = (j * 7) + 2 + k
        If p > u Then Exit Sub
        ActiveCell.Offset(j, k).Value = s((j * 7) + 2 + k)
    Next k
Next j

End Sub

I am sure with a bit of a hack we can get something, assuming CRLF is the break in your data

I will see what I can come up with, its gonna be a lot simpler than the one above
 
Upvote 0
ok in a much simpler version this does the biz, for me anyway

Code:
Sub paste2()
Dim myData As DataObject

Set myData = New DataObject
myData.GetFromClipboard
strnsra = myData.GetText

s = Split(strnsra, vbCrLf)
u = UBound(s)
k = 0
For j = u To 0 Step -1
    ActiveCell.Offset(0, k).Value = s(j)
    k = k + 1
Next j

End Sub
 
Upvote 0

Forum statistics

Threads
1,203,670
Messages
6,056,666
Members
444,881
Latest member
Stu2407

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