Gruppe
Dialog
Problem
Wie kann ich aus einer mehrspaltigen ListBox alle markierten Werte der ersten Spalte in die Zwischenablage übernehmen?
StandardModule: basMain
Sub CallForm()
frmAuslesen.Show
End Sub
ClassModule: frmAuslesen
Private Sub cmdAbbrechen_Click()
Unload Me
End Sub
Private Sub cmdAuslesen_Click()
Dim iCounter As Integer
Dim oClip As DataObject
Dim sTxt As String
Set oClip = New DataObject
For iCounter = 1 To lstAuslesen.ListCount - 1
If lstAuslesen.Selected(iCounter) Then
sTxt = sTxt & lstAuslesen.List(iCounter, 0) & vbLf
End If
Next iCounter
sTxt = Left(sTxt, Len(sTxt) - 1)
oClip.SetText sTxt
oClip.PutInClipboard
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim arr(1 To 20, 1 To 2) As Variant
Dim iRow As Integer
For iRow = 1 To 20
arr(iRow, 1) = iRow
arr(iRow, 2) = "Element " & iRow
Next iRow
lstAuslesen.List = arr
End Sub