Laufzeitfehler 1004
25.06.2020 09:49:05
Antje
ich bin dezent verzweifelt gerade, ich habe einen Code mit Schleife:
Dim last As Long
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
With ThisWorkbook.Worksheets("VVP-Tool")
If Phase.Value = 1 Then
last = .Range("D12").End(xlDown).Row() + 1
.Cells(last, 4).Value = UserForm1.TextNr.Value
.Cells(last, 5).Value = UserForm1.TextTitel.Value
.Cells(last, 6).Value = UserForm1.TextDatum.Value
.Cells(last, 7).Value = UserForm1.TextAllgemein.Value
.Cells(last, 8).Value = UserForm1.TextAktivitäten.Value
End If
If Phase.Value = 2 Then
a = .Range("J12").End(xlDown).Row() + 1
.Cells(a, 10).Value = UserForm1.TextNr.Value
.Cells(a, 11).Value = UserForm1.TextTitel.Value
.Cells(a, 12).Value = UserForm1.TextDatum.Value
.Cells(a, 13).Value = UserForm1.TextAllgemein.Value
.Cells(a, 14).Value = UserForm1.TextAktivitäten.Value
End If
If Phase.Value = 3 Then
b = .Range("P12").End(xlDown).Row() + 1
.Cells(b, 16).Value = UserForm1.TextNr.Value
.Cells(b, 17).Value = UserForm1.TextTitel.Value
.Cells(b, 18).Value = UserForm1.TextDatum.Value
.Cells(b, 19).Value = UserForm1.TextAllgemein.Value
.Cells(b, 20).Value = UserForm1.TextAktivitäten.Value
End If
If Phase.Value = 4 Then
c = .Range("V12").End(xlDown).Row() + 1
.Cells(c, 22).Value = UserForm1.TextNr.Value
.Cells(c, 23).Value = UserForm1.TextTitel.Value
.Cells(c, 24).Value = UserForm1.TextDatum.Value
.Cells(c, 25).Value = UserForm1.TextAllgemein.Value
.Cells(c, 26).Value = UserForm1.TextAktivitäten.Value
End If
If Phase.Value = 5 Then
d = .Range("AB12").End(xlDown).Row() + 1
.Cells(d, 28).Value = UserForm1.TextNr.Value
.Cells(d, 29).Value = UserForm1.TextTitel.Value
.Cells(d, 30).Value = UserForm1.TextDatum.Value
.Cells(d, 31).Value = UserForm1.TextAllgemein.Value
.Cells(d, 32).Value = UserForm1.TextAktivitäten.Value
End If
End With
Unload UserForm1
End Sub
Bei 1 und 3 für Phase klappt alles mehr wie einwandfrei und ich bin total glücklich, doch wenn ich 2,4 oder 5 für Phase in meiner Userform eingebe kommt immer Laufzeitfehler 1004n objekt/ Anwendungsfehler, ich finde aber keinen Unterschied zwischen den Codes, verbundene Zellen habe ich nicht. Hat jemand von euch ne Idee?
Ganz liebe Grüße