Hi all,
I have created a UserForm with a ListBox. I would need to use the default CTRL + C to copy data from the ListBox. Is there such a possibility?
Thank you for your help in advance.
Hi all,
I have created a UserForm with a ListBox. I would need to use the default CTRL + C to copy data from the ListBox. Is there such a possibility?
Thank you for your help in advance.
Seems related to your previous post. What is your outcome objective? Copy the listbox selection to where, or copy the whole listbox contents somewhere? Dave
Yes, right, related to my previous post. Yes, right, related to my previous post. I want copy one value from listbox to web browser or to other applications.
You don't need to copy the selected value. For example, U can assign the selected listbox1 item in Userform1 to a variable as follows ...
You would then pass that value to your web browser or other application. HTH. DaveDim SomeVariableName as String SomeVariableName = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex)
Need to paste the code into the UserForm code?
U can trial this...
Module code..
Userform code...Public SomeVariableName as String
If U select something in listbox1, you can then use the SomeVariableName for whatever U want. U can even close the userform and the Variable value will persist (if U have placed the variable declaration at the top of a module as indicated). DavePrivate Sub ListBox1_Click() SomeVariableName = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex) End Sub
Thanks for help. I solved problem again with button and code:
Private Sub CommandButton4_Click()
Dim clipboard As MSForms.dataObject
Dim strSample As String
Set clipboard = New MSForms.dataObject
strSample = UserForm1("ListBox1").Value
clipboard.SetText strSample
clipboard.PutInClipboard
End Sub
It can be done more concisely:
Private Sub ListBox1_Click() With GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") .SetText ListBox1 .PutInClipboard End With End Sub