In etwa so (Quellcode kommt in die Tabelle in der sich ComboBox1 befindet):
Option Explicit
Private Enum ProductValue
pdvPrice = 1
pdvWeight
pdvAmount
End Enum
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex < 0 Then Exit Sub
With ComboBox1
Cells(3, "B").Value = .List(.ListIndex, pdvPrice)
Cells(3, "C").Value = .List(.ListIndex, pdvWeight)
Cells(3, "D").Value = .List(.ListIndex, pdvAmount)
End With
End Sub
Private Sub Init() 'einmal ausführen
Application.EnableEvents = False
With ComboBox1
.Placement = XlPlacement.xlFreeFloating
.Style = fmStyleDropDownList
.Left = Range("B2").Left
.Top = Range("B2").Top
.Width = 125
.Height = 20
Rows(2).RowHeight = .Height
.ColumnCount = 1
.Clear
.AddItem "Milch"
.List(.ListCount - 1, pdvPrice) = "1 Euro"
.List(.ListCount - 1, pdvWeight) = "2 kg"
.List(.ListCount - 1, pdvAmount) = "3 stk"
.AddItem "Käse"
.List(.ListCount - 1, pdvPrice) = "4 Euro"
.List(.ListCount - 1, pdvWeight) = "5 kg"
.List(.ListCount - 1, pdvAmount) = "6 stk"
.AddItem "Wasser"
.List(.ListCount - 1, pdvPrice) = "7 Euro"
.List(.ListCount - 1, pdvWeight) = "8 kg"
.List(.ListCount - 1, pdvAmount) = "9 stk"
End With
Application.EnableEvents = True
End Sub
|