Hallo,
wie kann ich den o.g. Fehler lösen?
Was passiert:
Ich hab eine Userform und darin Listboxen
Die Listbox beginnt automatisch bei der Zahl 0
Wenn jedoch nur 1 listbox verändert wird, und die anderen nicht und auf 0 bleiben, dann erscheint der o.g. Fehler
Mein Code:
Private Sub CommandButton1_Click()
Range("C6").Value = Range("C6") - ListBox1.Value
Range("D6").Value = Range("D6") - ListBox2.Value
Range("F6").Value = Range("F6") + ListBox3.Value
Range("G6").Value = Range("G6") + ListBox4.Value
Range("C10").Value = Range("C10") + ListBox1
Range("C11").Value = Range("C11") + ListBox2
Dim n
For n = 0 To ListBox1.ListCount - 1
ListBox1.Selected(n) = True
Next n
Dim m
For m = 0 To ListBox2.ListCount - 1
ListBox2.Selected(m) = True
Next m
Dim b As Long
For b = 0 To ListBox3.ListCount - 1
ListBox3.Selected(b) = True
Next b
Dim c As Long
For c = 0 To ListBox4.ListCount - 1
ListBox4.Selected(c) = True
Next c
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
'---
With ListBox1
ListBox1.List = Tabelle1.Range("C49:C59").Value
For n = 0 To ListBox1.ListCount - 1
ListBox1.Selected(n) = True
Next n
End With
'----
With ListBox2
ListBox2.List = Tabelle1.Range("C49:C59").Value
For m = 0 To ListBox2.ListCount - 1
ListBox2.Selected(m) = True
Next m
End With
'---
With ListBox3
ListBox3.List = Tabelle1.Range("C49:C59").Value
For b = 0 To ListBox3.ListCount - 1
ListBox3.Selected(b) = True
Next b
End With
'---
With ListBox4
ListBox4.List = Tabelle1.Range("C49:C59").Value
For c = 0 To ListBox4.ListCount - 1
ListBox4.Selected(c) = True
Next c
End With
End Sub