Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1352to1356
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Einmal Nein genügt mit MsgBox
02.04.2014 18:38:03
Heinz
Hallo Leute
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

8
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Einmal Nein genügt mit MsgBox
02.04.2014 19:02:44
Oberschlumpf
Hi Heinz
so auf die Schnelle schreib mal zusätzlich diese Dim-Zeile zu den anderen.

Dim lboRepeat As Boolean
Und anstelle von

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

schreibst du

If lboRepeat = False Then
If MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", vbYesNo + vbQuestion, "Ü _
berschreiben ?") = vbYes Then
lboRepeat = True
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

Hilfts?
Wenn nicht, bitte eine Bsp-Datei.
Ciao
Thorsten

Anzeige
AW: Einmal Nein genügt mit MsgBox
02.04.2014 19:43:44
Uwe
Hallo Heinz, (schöner Name übrigens..:-)
wie ich das sehe, wird egal was du tust, das selbe ausgeführt. Oder steh ich grad auf'm Schlauch.
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
Probier mal so.
If Ws.Cells(j, 2) "" Then
If MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", vbYesNo + vbQuestion, "Überschreiben?") = vbNo Then
Exit Sub
Else
Ws.Cells(j, 2) = ComboBoxSAP
Ws.Cells(j, 3) = TextBox7
Ws.Cells(j, 4) = TextBox6
End If
End If
Next j
Grüße Heinz

Anzeige
AW: Einmal Nein genügt mit MsgBox
02.04.2014 19:57:17
HeinzK
ohh sorry, um keine Verwirrung zu stiften... Uwe ist mein "Jüngster"(21). Hab versehentlich unter seinem Namen gepostet, da wir gelegentlich den selben Rechner nutzen :-)
Grüße Heinz

vergiss meine Idee, is falsch...owT
02.04.2014 19:04:16
Oberschlumpf

AW: Einmal Nein genügt mit MsgBox
02.04.2014 19:16:37
fcs
Hallo Heinz,
mit folgenden Anpasungen sollte die Rückfrage nur noch einmal angezeigt werden, wenn auf "Ja" geklickt wird.
Gruß
Franz
'Hier werden die Werte eingetragen
Private Sub CommandButtonEintragen_Click()
Dim j As Integer
Dim lZeile As Integer
Dim Ws As Worksheet
Dim varAntwort As Variant
'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
varAntwort = vbNo
For j = 2 To lZeile
If CDate(Ws.Cells(j, 1)) >= CDate(ComboBoxDatum_von.Text) _
And CDate(Ws.Cells(j, 1))  "" Then
If varAntwort = vbNo Then
varAntwort = MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", _
vbYesNo + vbQuestion, "Überschreiben ?")
End If
If varAntwort = 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
varAntwort = vbNo
'Unload Me
ComboBoxSAP = ""
ComboBoxLinie = ""
TextBoxTage = ""
TextBoxEnde = ""
TextBox6 = ""
TextBox7 = ""
End Sub

Anzeige
AW: Einmal Nein genügt mit MsgBox
02.04.2014 19:25:02
Heinz
Hallo Franz
Erstmals Danke.
Ich würde aber auch das selbe benötigen,wenn ich auf Nein klicke.
Danke & Gruß Heinz

AW: Einmal Nein genügt mit MsgBox
03.04.2014 01:40:02
fcs
Hallo Heinz,
dann evtl. so
Gruß
Franz
'Hier werden die Werte eingetragen
Private Sub CommandButtonEintragen_Click()
Dim j As Integer
Dim lZeile As Integer
Dim Ws As Worksheet
Dim varAntwort As Variant, bolSchreiben As Boolean
'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
varAntwort = vbNo
For j = 2 To lZeile
If CDate(Ws.Cells(j, 1)) >= CDate(ComboBoxDatum_von.Text) _
And CDate(Ws.Cells(j, 1))  "" Then
If varAntwort = vbNo Then
bolSchreiben = MsgBox("Wollen Sie den Auftrag wirklich überschreiben.", _
vbYesNo + vbQuestion, "Überschreiben ?") = vbYes
varAntwort = vbYes
End If
If bolSchreiben = True 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
varAntwort = vbNo
'Unload Me
ComboBoxSAP = ""
ComboBoxLinie = ""
TextBoxTage = ""
TextBoxEnde = ""
TextBox6 = ""
TextBox7 = ""
End Sub

Anzeige
Danke Franz
03.04.2014 12:19:14
Heinz
Hallo Franz
Funktioniert Prima.
Recht herzlichen Dank,gruß
Heinz

278 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige