Ich habe den VBA Code noch erweitert, um zwei Textboxen ( TBName und TBNr).
Leider kommt eine Fehlermeldung bei der ersten If Controls, was habe ich da Falsch gemacht?
In TBPreis gebe ich auch Werte ein!!
Wenn mir auch jemannd anderes helfen möchte währe ich auch Dankbar.
Private Sub CommandButton14_Click()
Dim LetzteZeile As Long
Dim iTB As Byte
For iTB = 1 To 8
If Controls("TBName" & "TBNr" & "TBDatum" & "TBPreis" & iTB) <> "" Then
If Not IsDate(Controls("TBName" & "TBNr" & "TBDatum" & "TBPreis" & iTB)) Then
MsgBox "TBName" & "TBNr" & "TBDatum" & "TBPreis" & iTB & " enthält kein Eingabe. Bitte korrigieren.", vbInformation, "Programmabbruch"
Controls("TBName" & "TBNr" & "TBDatum" & "TBPreis" & iTB).SetFocus
Exit Sub
End If
End If
Next iTB
With ActiveSheet
LetzteZeile = .Range("D89").End(xlUp).Row
If LetzteZeile < 52 Then LetzteZeile = 89
For iTB = 1 To 8
If Controls("TBName" & "TBNr" & "TBDatum" & "TBPreis" & iTB) = "" Then
Exit Sub
If .Range("D89") <> "" Then
MsgBox "Tabelle ist voll. Es können keine weiteren Daten übertragen werden.", vbCritical, "Fehler"
Exit Sub
Else
.Cells(LetzteZeile + iTB, 1) = Controls("TBName" & iTB)
.Cells(LetzteZeile + iTB, 2) = Controls("TBNr" & iTB)
.Cells(LetzteZeile + iTB, 3) = CDate(Controls("TBDatum" & iTB))
.Cells(LetzteZeile + iTB, 4) = Controls("TBPreis" & iTB)
Controls("TBDatum" & iTB) = ""
End If
Next iTB
End With
End Sub
Gruß Torte