Fehler neue Zeile
01.07.2025 17:28:58
Tobias
Private Sub CommandButton4_Click()
Blattschutz_aufheben
Dim ws As Worksheet
Dim lastRow As Long
Dim searchValue As String
Dim newRow As Long
Dim neu As Range
'setze das Arbeitsblatt
Set ws = ThisWorkbook.Sheets("ÜBERSICHT")
'werte setzen
Dim TextBox1Value As String
Dim TextBox2Value As String
Dim TextBox3Value As String
Dim TextBox4Value As String
Dim ComboBox2Value As String
Dim ComboBox3Value As String
TextBox1Value = Me.TextBox1.Value
TextBox2Value = Me.TextBox2.Value
TextBox3Value = Me.TextBox3.Value
TextBox4Value = Me.TextBox4.Value
ComboBox2Value = Me.ComboBox2.Value
ComboBox3Value = Me.ComboBox3.Value
'überprüfung ob alles ausgefüllt ist
If TextBox1Value = "" Or TextBox1Value = "" Or TextBox1Value = "" Or ComboBox2Value = "" Or ComboBox3Value = "" Then
MsgBox "Bitte alles ausfüllen!", vbExclamation, "Eingabe überprüfen"
Exit Sub
End If
'suche den letzten wert
lastRow = ws.Cells(ws.Rows.Count, 4).End(xlUp).Row 'Spalte C (Combobox3)
'finde die Zeile die den wert enthält
For I = 1 To lastRow
If ws.Cells(I, 4).Value = ComboBox3Value Then
newRow = I + 1 'neue Zeile unter der gefundenen
Exit For
End If
Next I
' Füge die Werte ein die neue Zeile ein
ws.Cells(newRow, 1).Value = TextBox1Value ' spalte A
ws.Cells(newRow, 2).Value = TextBox2Value ' spalte B
ws.Cells(newRow, 3).Value = TextBox4Value ' spalte C
ws.Cells(newRow, 7).Value = TextBox3Value ' spalte G
ws.Cells(newRow, 4).Value = ComboBox3Value ' spalte D
ws.Cells(newRow, 5).Value = "0" ' spalte E
ws.Cells(newRow, 9).Value = ComboBox2Value ' spalte I
MsgBox "Neues Werkzeug angelegt."
Datum
Bestand_Zaehlen
FRAGE
End Sub
Vielen Dank schon mal für eure Hilfe! :)
Anzeige