svacx
svacx

Reputation: 357

Copy from clipboard and paste into a userform

I am using a program that populates a table with data, and the sizes (col/row) of these table grows every period in an unpredicted way.

So let's say I copy the contents of the table into clipboard, and what I want to know is:

Is it possible to paste this data into some sort of userform instead of going to an Excel sheet and then loading the source into a listbox?

I couldn't find any source material on this. I was interested to know if it was possible or if not, why it's not a good idea to do this!

I did find a lot of material about using the source of a table to populate a listbox, or, using a right click to copy data from a userform, but not the other way around.

Upvotes: 1

Views: 3113

Answers (1)

KyloRen
KyloRen

Reputation: 2741

This copyies any info in the current selection in clipboard and puts it into a textbox,

Dim clipBoard As MsForms.DataObject
Set clipBoard = New MsForms.DataObject

clipBoard.GetFromClipboard
TextBox1.Value = clipBoard.GetText(1)

Of course you can adapt this to have the data put into different form controls. You will need to handle when the clipboard is empty.

Upvotes: 1

Related Questions