Die Methode Value für.... Automatisierungsfehler
14.02.2017 12:18:53
Xanaa
nach langer Abwesenheit bitte ich noch einmal um Eure geschätzte Hilfe:
Unser Betrieb hat auf Excel 2013 umgestellt.
Nun tritt in einer UserForm ein Problem auf, dem ich nicht auf die Spur komme:
Es werden aus der User Form Eingaben in eine Liste geschrieben. Beim Klick auf den Button zur Übernahme folgt "214717848 (80010108) - Die Methode Value für das Objekt Range ist fehlgeschlagen" .
Ich starte den Debugger, es folgt "Automatisierungsfehler. Das aufgerufene Objekt wurde vom Client getrennt"
Egal wohin ich nun klicke, Excel verabschiedet sich im Nirwana (Neustart / Beenden)
Ich habe das mal komplett einkopiert:
Die Abfrage der leeren Felder funktioniert noch, bei der Variablen "p" hängt es dann ( an der Stelle .Range("A" & p).Value = ComboBox7.Text)
Hat jemand eine Idee für mich? Achtung, ihr müsst mir das für Dumme erklären, hab nicht viel Erfahrung....
Euch schon mal ein großes Dankeschön!
Private Sub CommandButton1_Click()
Dim p As Long
If TextBox1.Text = "" Or _
ComboBox1.Value = "" Or _
ComboBox2.Value = "" Or _
ComboBox3.Value = "" Or _
ComboBox4.Value = "" Or _
ComboBox5.Value = "" Or _
ComboBox6.Value = "" Or _
ComboBox7.Value = "" Then
MsgBox "Bitte alle Felder ausfüllen!", vbInformation, "Hinweis"
Exit Sub
End If
With Sheets("Verbrauchsliste")
p = IIf(IsEmpty(.Range("A65536")), .Range("A65536").End(xlUp).Row, 65536) + 1
.Range("A" & p).Value = ComboBox7.Text
.Range("B" & p).Value = ComboBox1.Text
ComboBox1.Text = ""
.Range("C" & p).Value = ComboBox2.Text
ComboBox2.Text = ""
.Range("D" & p).Value = ComboBox3.Text
ComboBox3.Text = ""
.Range("E" & p).Value = ComboBox4.Text
ComboBox4.Text = ""
.Range("F" & p).Value = ComboBox5.Text
ComboBox5.Text = ""
.Range("G" & p).Value = TextBox1.Text
TextBox1.Text = ""
.Range("H" & p).Value = ComboBox6.Text
ComboBox6.Text = ""
'usw. für die restlichen ComboBoxen.
ListBox1.RowSource = .Range("A3:H" & p).Address(External:=True)
End With
End Sub
Private Sub ComboBox1_Change()
TextBox2 = Date
End Sub
Private Sub CommandButton2_Click()
If TextBox3.Text "geheim" Then
Application.Quit
Else
Unload Me
End If
End Sub
Private Sub Label12_Click()
End Sub
Private Sub Label8_Click()
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim p As Long, q As Long
q = ListBox1.ListCount
If ListBox1.ListIndex
MsgBox "Dieser Eintrag kann nicht mehr geändert werden!", vbCritical, "Hinweis"
Exit Sub
End If
p = ListBox1.ListIndex + 3
ComboBox1.Value = Range("B" & p).Value
ComboBox2.Value = Range("C" & p).Value
ComboBox3.Value = Range("D" & p).Value
ComboBox4.Value = Range("E" & p).Value
ComboBox5.Value = Range("F" & p).Value
ComboBox6.Value = Range("H" & p).Value
ComboBox7.Value = Range("G" & p).Value
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub UserForm_Initialize()
Dim z As Long, lz As Long
With Sheets("Listbox-Felder")
ListBox1.ColumnWidths = "110 Pt;150 Pt;40 Pt; 40 Pt;100 Pt;70 Pt"
For z = 3 To .Cells(65536, 1).End(xlUp).Row
ComboBox1.AddItem .Cells(z, 1).Value
Next z
For z = 3 To .Cells(65536, 2).End(xlUp).Row
ComboBox2.AddItem .Cells(z, 2).Value
Next z
For z = 3 To .Cells(65536, 3).End(xlUp).Row
ComboBox3.AddItem .Cells(z, 3).Value
Next z
For z = 3 To .Cells(65536, 4).End(xlUp).Row
ComboBox4.AddItem .Cells(z, 4).Value
Next z
For z = 3 To .Cells(65536, 5).End(xlUp).Row
ComboBox5.AddItem .Cells(z, 5).Value
Next z
For z = 3 To .Cells(65536, 6).End(xlUp).Row
ComboBox6.AddItem .Cells(z, 6).Value
Next z
For z = 3 To .Cells(65536, 7).End(xlUp).Row
ComboBox7.AddItem .Cells(z, 7).Value
Next z
End With
With Sheets("Verbrauchsliste")
lz = .Cells(65536, 1).End(xlUp).Row
ListBox1.RowSource = .Range("A3:H" & lz).Address(External:=True)
ListBox1.ColumnHeads = True
End With
Me.Top = 0
Me.Left = 0
Me.Height = Application.Height
Me.Width = Application.Width
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If TextBox3.Text "geheim" Then Cancel = True
End Sub