VBA fügt Daten in falsche Zeile
17.07.2020 12:30:37
Herbert
ich melde mich auf ein neues und diesmal verwirrt der Fehler mich..., sobald ich diesen Code ausführe:
ElseIf Bestätigen.Caption = "Bearbeiten" Then
Dim finden As Range
Set finden = Worksheets("Zugmaschinen").[SZM].Find(what:=TextBox_Kennzeichen)
TextBox_Zellen_Adresse = finden.Address
Dim CBoxTxt As String, findRow As Long
CBoxTxt = TextBox_Kennzeichen.Text
findRow = Range(TextBox_Zellen_Adresse).Row
If Not finden Is Nothing Then 'If Cells(findRow, 1) = CBoxTxt Then
Eingabewert_1 = MsgBox("Soll der Auflieger " & CBoxTxt & " wirklich bearbeitet werden? _
", vbYesNo, "Sicherheitsfrage")
If Eingabewert_1 = vbNo Then
Unload Me
Exit Sub
ElseIf Eingabewert_1 = vbYes Then
With Worksheets("Zugmaschinen").[SZM]
.Cells(findRow, 2) = CInt(TextBox_Achsen.Value)
.Cells(findRow, 3) = Format(TextBox_A1.Value, "##,##0.00")
.Cells(findRow, 4) = Format(TextBox_A1_A2.Value, "##,##0.00")
If TextBox_Achsen.Value = "4" Or TextBox_Achsen.Value = "3" Then
.Cells(findRow, 5) = Format(TextBox_A2_A3.Value, "##,##0.00")
End If
If TextBox_Achsen.Value = "4" Then
.Cells(findRow, 6) = Format(TextBox_A3_A4, "##,##0.00")
End If
.Cells(findRow, 7) = Format(TextBox_A4.Value, "##,##0.00")
.Cells(findRow, 8) = Format(TextBox_AL1.Value, "##,##0.00")
.Cells(findRow, 9) = Format(TextBox_AL2.Value, "##,##0.00")
If TextBox_Achsen.Value = "4" Or TextBox_Achsen.Value = "3" Then
.Cells(findRow, 10) = Format(TextBox_AL3.Value, "##,##0.00")
End If
If TextBox_Achsen.Value = "4" Then
.Cells(findRow, 11) = Format(TextBox_AL4.Value, "##,##0.00")
End If
.Cells(findRow, 12) = CInt(TextBox_Räder_A1.Value)
.Cells(findRow, 13) = CInt(TextBox_Räder_A2.Value)
If TextBox_Achsen.Value = "4" Or TextBox_Achsen.Value = "3" Then
.Cells(findRow, 14) = CInt(TextBox_Räder_A3.Value)
End If
If TextBox_Achsen.Value = "4" Then
.Cells(findRow, 15) = CInt(TextBox_Räder_A4.Value)
End If
.Cells(findRow, 16) = Format(TextBox_A_Maß_1.Value, "##,##0.00")
.Cells(findRow, 17) = Format(TextBox_A_Maß_2.Value, "##,##0.00")
.Cells(findRow, 18) = Format(TextBox_A_Maß_3.Value, "##,##0.00")
.Cells(findRow, 19) = Format(TextBox_A_Maß_4.Value, "##,##0.00")
.Cells(findRow, 20) = Format(TextBox_A_Maß_5.Value, "##,##0.00")
.Cells(findRow, 21) = Format(TextBox_A_Maß_6.Value, "##,##0.00")
.Cells(findRow, 22) = Format(TextBox_A_Maß_7.Value, "##,##0.00")
.Cells(findRow, 23) = Format(TextBox_A_Maß_8.Value, "##,##0.00")
.Cells(findRow, 24) = Format(TextBox_A_Maß_9.Value, "##,##0.00")
.Cells(findRow, 25) = Format(TextBox_A_Maß_Standard.Value, "##,##0.00")
.Cells(findRow, 26) = Format(TextBox_KPV_Rad.Value, "##,##0.00")
.Cells(findRow, 27) = Format(TextBox_KPH_Rad.Value, "##,##0.00")
If TextBox_KP.Value = "" Then
GoTo Nächster
Else
.Cells(findRow, 28) = CInt(TextBox_KP.Value)
End If
Nächster:
.Cells(findRow, 31) = Format(TextBox_13SL.Value, "##,##0.00")
.Cells(findRow, 32) = Format(TextBox_G.Value, "##,##0.00")
.Cells(findRow, 33) = Format(TextBox_F2.Value, "##,##0.00")
.Cells(findRow, 37) = CInt(TextBox_Antriebsachsen.Value)
.Cells(findRow, 38) = TextBox_FIN.Value
.Cells(findRow, 39) = CInt(TextBox_BABH.Value)
.Cells(findRow, 40) = CInt(TextBox_Max_Z_Ge_G.Value)
.Cells(findRow, 42) = TextBox_Hersteller.Value
.Cells(findRow, 43) = TextBox_Radstand.Value
End With
Unload Me
SZM_hinzufuegen_2.Show
End If
Soll er mir die Datensätze eigentlich in der selben Zeile wo auch das Kennzeichen ist einfügen, aber VBA findet es witziger die Datensätze einfach 33 Zeilen weiter unten einzufügen... .Die Userform worüber dieser Code ausgeführt wird befindet sich auf dem Tabellenblatt("Ausleser") und das wo die Daten eingefügt werden sollen auf dem Tabellenblatt("Zugmaschinen").
Falls Bsp.-Datei benötigt, bitte ebend schreiben!
Danke schon einmal im Voraus!
MfG Herbert!