Gruppe
Dialog
Problem
Wie kann ich Waren aus einer UserForm-ListBox in eine WarenkorbListBox übertragen und in eine Einkaufsliste eintragen lassen?
StandardModule: basMain
Sub CallForm()
frmVerkauf.Show
End Sub
ClassModule: frmVerkauf
Private Sub cmdEintragen_Click()
Dim iRow As Integer, iRowL As Integer, iCol As Integer
iRowL = Cells(Rows.Count, 1).End(xlUp).Row + 1
For iRow = 0 To lstKorb.ListCount - 1
For iCol = 0 To 2
Cells(iRowL + iRow, iCol + 1) = lstKorb.List(iRow, iCol)
Next iCol
Next iRow
lstKorb.Clear
Columns.AutoFit
End Sub
Private Sub cmdAbbrechen_Click()
Unload Me
End Sub
Private Sub lstWaren_Click()
Dim iCounter As Integer
lstKorb.AddItem
For iCounter = 0 To 2
If iCounter < 2 Then
lstKorb.List(lstKorb.ListCount - 1, iCounter) = _
lstWaren.List(lstWaren.ListIndex, iCounter)
Else
lstKorb.List(lstKorb.ListCount - 1, iCounter) = _
Format(lstWaren.List(lstWaren.ListIndex, iCounter), "0.00")
End If
Next iCounter
End Sub
Private Sub lstKorb_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
lstKorb.RemoveItem lstKorb.ListIndex
End Sub
Private Sub UserForm_Initialize()
Dim wks As Worksheet
Dim iRow As Integer
Set wks = Worksheets("Waren")
iRow = wks.Cells(Rows.Count, 1).End(xlUp).Row
With lstWaren
.RowSource = wks.Name & "!A2:C" & iRow
.ColumnWidths = "40;80;60"
End With
lstKorb.ColumnWidths = "40;80;60"
End Sub