über eine ComboBox wähle ich einen Artikel aus, dann will ich, dass mir in einer TextBox das Ergebnis der Differenz der Zellen M - S angezeigt wird.
Habe es mit folgendem Code versucht, aber es wird nix gerechnet.
Private Sub ComboBox1_Change()
Dim s As String
Dim erg As Currency
'erg = 0
Set frm = UserForm10
s = frm.ComboBox1.Text
Dim i As Integer
Dim iMax As Integer
Application.ScreenUpdating = False
iMax = ActiveSheet.UsedRange.Rows.count
For i = 5 To iMax
If Worksheets("All Parts2006").Cells(i, 2) = s Then
erg = Worksheets("All Parts2006").Cells(i, 13) - Worksheets("All Parts2006").Cells(i, 19)
Else
End If
Next i
frm.TextBox1.Text = Format(erg, "[$$-409]#,##0.00") & " $"
Application.ScreenUpdating = True
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub UserForm_Initialize()
Dim aRow, i As Variant
Application.EnableEvents = False
ComboBox1.Clear
aRow = [B65536].End(xlUp).Row
ComboBox1.AddItem ""
For i = 5 To aRow
ComboBox1.AddItem Cells(i, 2) & ", " & Cells(i, 3)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub
Vielleicht sieht von euch jemand den Fehler.
Gruß & Danke
Brunito