Einmal Nein genügt mit MsgBox
02.04.2014 18:38:03
Heinz
Ich habe eine UF,mittels Text & ComboBoxen trage ich Werte in verschiedene Sheets für verschiedene Tagen ein.
Funktioniert auch tadellos,Nur wenn die Abfrage kommt
If MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", vbYesNo + vbQuestion, "Überschreiben ?") = vbYes Then
Und ich habe zB. für 5 Tage den Wert eingegeben,dann kommt die Meldung 5 mal, & ich muß 5 mal die MsgBox bestätigen.
Wie würde es bitte gehen das nach einmal bestätigen der Code beendet wird?
Danke & gruß,Heinz
'Hier werden die Werte eingetragen
Private Sub CommandButtonEintragen_Click()
Dim j As Integer
Dim lZeile As Integer
Dim Ws As Worksheet
'Fehler abfangen
If ComboBoxSAP = "" Then
MsgBox "Es wurde keine SAP Nummer eingegeben!"
Exit Sub
Else
End If
If ComboBoxLinie = "" Then
MsgBox "Sie haben keine Linie ausgewählt!"
Exit Sub
Else
End If
If TextBoxTage = "" Then
MsgBox "Es wurde keine Laufzeit in Tagen eingegeben!"
Exit Sub
Else
End If
If TextBoxEnde = "" Then
MsgBox "Sie haben nicht auf Berechnen gedrückt!"
Exit Sub
Else
End If
Set Ws = Sheets(ComboBoxLinie.Text)
lZeile = Ws.Cells(Rows.Count, 1).End(xlUp).Row
For j = 2 To lZeile
If CDate(Ws.Cells(j, 1)) >= CDate(ComboBoxDatum_von.Text) And CDate(Ws.Cells(j, 1)) "" Then
If MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", vbYesNo + vbQuestion, "Ü _
berschreiben ?") = vbYes Then
Ws.Cells(j, 2) = ComboBoxSAP
Ws.Cells(j, 3) = TextBox7
Ws.Cells(j, 4) = TextBox6
End If
Else
Ws.Cells(j, 2) = ComboBoxSAP
Ws.Cells(j, 3) = TextBox7
Ws.Cells(j, 4) = TextBox6
End If
End If
Next j
'Unload Me
ComboBoxSAP = ""
ComboBoxLinie = ""
TextBoxTage = ""
TextBoxEnde = ""
TextBox6 = ""
TextBox7 = ""
End Sub