Excel Excel 2003; Multiple listbox items putinclipboard

Joined
Apr 6, 2011
Messages
1
Reaction score
0
Hi,

I have an userform containing 1 listbox and 1 commandbutton. The listbox contains about 10 items which are used to describe a certain kind of issue. By clicking the commandbutton the procedure checks which listbox.listindex is selected and finds a corresponding line of text manually programmed. This works fine, but what I want to do now is selecting multiple items and put them in a clipboard. Enclosed is the main pice of code I'm using now, what I'm looking for is an alternation so that multiple items (strings) are selected and copied to the clipboard.

Sub UserForm_Initialize()

' Fill the list box
With ListBox1
.AddItem "Wrong Inbox"
.AddItem "Wrong logging"
.AddItem "Missing Details"
End with
End sub

Private Sub CommandButton1_Click()

On Error Resume Next

Dim MyData As DataObject
Set MyData = New DataObject

If ListBox1.ListIndex = 0 Then
MyData.Clear
MyData.SetText "You have selected wrong inbox"
MyData.PutInClipboard
End If
If ListBox1.ListIndex = 1 Then
MyData.Clear
MyData.SetText "You have selected wrong logging"
MyData.PutInClipboard
Unload Me
End If
If ListBox1.ListIndex = 2 Then
MyData.Clear
MyData.SetText "Pleae provide missing details"
MyData.PutInClipboard
Unload Me
End If
End sub

Any help would be much appreciated!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top