0

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.

Community
  • 1
  • 1
svacx
  • 327
  • 2
  • 4
  • 19
  • 1
    since you know how to populate a listbox from a source table, why don't you do that right before (and avoid) copying data into clipboard? – user3598756 Jan 04 '17 at 10:04
  • 1
    Post some code and we'll try to help if it's not working. And yes you are right, it is a stupid question for SO. – Mark Fitzgerald Jan 04 '17 at 10:27
  • Where do you recommend posting this into? @MarkFitzgerald – svacx Jan 04 '17 at 10:36
  • 1
    I don't think it is possible. If I remember correctly you can assign all items at once `ListBox1.List = Split("a b c")` – Slai Jan 04 '17 at 10:36
  • 1
    A perfectly reasonable question. – S Meaden Jan 04 '17 at 12:35
  • 1
    See also: http://stackoverflow.com/questions/5552299/how-to-copy-to-clipboard-using-access-vba (identical for Access and Excel, since it's both VBA) – Cody Gray Jan 04 '17 at 12:59

1 Answers1

1

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.

Cerbrus
  • 65,559
  • 18
  • 128
  • 140
KyloRen
  • 2,559
  • 5
  • 27
  • 53