AW: Userform doppelte werte auswerten
11.06.2024 11:40:10
simsek
Hallo MCO,
danke für mdeine anregung und Antwort.
hier ist der VBA Code wo ich nur einen Wert überprüfe:
Private Sub Speichern_Click()
If TextBoxBA.Value = "" Or TextBoxEP.Value = "" Or ComboBoxDT.Value = "" Or ComboBoxMT.Value = "" Or ComboBoxFG.Value = "" Or ComboBoxFE.Value = "" Or ComboBoxP.Value = "" Or ComboBoxBLDC.Value = "" Or ComboBoxKW.Value = "" Then
MsgBox "Bitte fülle alle Pflichtelder mit* aus!", , ""
Exit Sub
End If
If Application.CountIf(Sheets("Liste").Range("f11:f5000"), TextBoxSNRD) > 0 Then
MsgBox "Die Seriennummer RD ist schon vorhanden!", vbExclamation
Exit Sub
End If
If Application.CountIf(Sheets("Liste").Range("g11:g5000"), TextBoxSNMT) > 0 Then
MsgBox "Die Seriennummer Motor ist schon vorhanden!", vbExclamation
Exit Sub
End If
'Daten ins Tabellenblatt eintragen
Dim neuezeile As Long
With shliste
neuezeile = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Cells(neuezeile, 1).Value = TextBoxID.Value
.Cells(neuezeile, 2).Value = TextBoxBA.Value
.Cells(neuezeile, 3).Value = TextBoxEP.Value
.Cells(neuezeile, 4).Value = ComboBoxDT.Value
.Cells(neuezeile, 5).Value = ComboBoxMT.Value
.Cells(neuezeile, 6).Value = TextBoxSNRD.Value
.Cells(neuezeile, 7).Value = TextBoxSNMT.Value
.Cells(neuezeile, 8).Value = ComboBoxFG.Value
.Cells(neuezeile, 9).Value = ComboBoxFE.Value
.Cells(neuezeile, 10).Value = ComboBoxP.Value
.Cells(neuezeile, 11).Value = ComboBoxBLDC.Value
.Cells(neuezeile, 12).Value = ComboBoxKW.Value
End With
'UserForm Schließen
Unload Me
End Sub
Ich Prüfe 2 TextBoxen auf den wert, was ja auch klappt. Nur ich Möchte beim Speichen auf der Userform die werte ComboBoxDT, TextBoxSNRD und TextBoxSNMT überprüfen!
Falls identische werte sind soll MessageBox kommen bzw. eine Warnung und soll nicht speichern. Falls ein wert von den drei Values unterschuiedlich ist dann soll ich speichern können auf dem Tabellenblatt bzw. Tabelle.
Gruß Mehmet