Live-Forum - Die aktuellen Beiträge
Datum
Titel
16.10.2025 17:40:39
16.10.2025 17:25:38
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Sub unterbrechen und fortsetzen

Forumthread: Sub unterbrechen und fortsetzen

Sub unterbrechen und fortsetzen
14.01.2004 13:35:27
Slimfast
Zum Duvel noch mal!
Wie kann ich ein Public

Sub CommantButton_click unterbrechen ohne das mir
Daten aus einem Userform in eine Tabelle geschrieben werden.

Sub soll bei einer NICHT_EINGABE (TEXT o. CombBOX)eine MsgBox öffnen und an der Stelle stehen bleiben wo der Text vergessen wurde ohne dabei die schon ausgefüllten
Textboxen zu leeren  oder in eine Tabelle zu schreiben.
Wenn alle Pflichtfelder gefüllt sind sollen die Daten in dem Gleichen CommandButton_1 in die tabelle geschreiben werden und alle Eintäge im Userform gelöscht werden.
Geht das ???
Public 

Sub CommandButton1_Click()
If ComboBox1 Like "" Then
Application.Run "VBAProject.Modul1.Pflichtcmbo"
Else: TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox10 = ""
TextBox11 = ""
TextBox12 = "1"
TextBox13 = ""
TextBox14 = ""
TextBox15 = ""
ComboBox2 = ""
End If
z = Range("B1").End(xlDown).Row + 1
If z > 65000 Then z = 2
Cells(z, 1) = ComboBox1
Cells(z, 2) = TextBox1
Cells(z, 3) = TextBox2
Cells(z, 4) = TextBox3
Cells(z, 5) = TextBox4
Cells(z, 6) = TextBox5
'Cells(z, 7) = CDbl(TextBox6)
Cells(z, 8) = TextBox7
'Cells(z, 9) = CDbl(TextBox8)
Cells(z, 10) = TextBox9
Cells(z, 11) = TextBox10
Cells(z, 12) = TextBox11
Cells(z, 13) = TextBox12
Cells(z, 14) = TextBox13
'Cells(z, 15) = CDate(TextBox14.Text)
Cells(z, 16) = ChekBox1
Cells(z, 17) = ComboBox2
Cells(z, 18) = OptionsButton1
Cells(z, 19) = OptionsButton2
Cells(z, 20) = TextBox16
'TextBox1 = ""
'TextBox2 = ""
'TextBox3 = ""
'TextBox4 = ""
'TextBox5 = ""
'TextBox6 = ""
'TextBox7 = ""
'TextBox8 = ""
'TextBox10 = ""
'TextBox11 = ""
'TextBox12 = "1"
'TextBox13 = ""
'TextBox14 = ""
'TextBox15 = ""
'ComboBox2 = ""
End Sub

Anzeige

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Sub unterbrechen und fortsetzen
14.01.2004 13:50:46
xXx
Hallo,
eigentlich anworte ich ja nicht auf NickNames.
Erst alle Pflichtfelder prüfen und ggfs die Sub verlassen.
Etwa so:
arrPflicht=Array("Textbox4","Textbox13","Textbox24")
for C=0 to ubound(arrPflicht)
if me.controls(arrPflicht(c))="" then
Msgbox "Bitte alles ausfüllen"
me.controls(arrPflicht(C)).setfocus
exit sub
end if
Gruß aus'm Pott
Udo
http://www.excelerator.de

P.S. Das Forum lebt auch von den Rückmeldungen an die Antworter!
Anzeige
An UDO noch eine Frage
14.01.2004 14:18:13
felix
Hallo Udo,
dieses Makro hatte mich auch interessiert
kannst Du mir netterweise nochmal sagen wie folgende Variable deklariert wird????
Dim arrPflicht As Range ?? geht nicht??
Danke
Gruß
Felix
String oder Variant (oT)
15.01.2004 13:14:29
xXx
AW: String oder Variant (oT)
15.01.2004 14:30:21
Slimfast
Hallo Felix
Hast Du den Zeilenumbruch __?
So klappt es.
Public

Sub CommandButton1_Click()
arrPflicht = Array("ComboBox1", "Textbox3", "Textbox4", "Textbox5", "Textbox6",__ "Textbox8", "Textbox9", "Textbox12", "Textbox13", "Textbox14", "ComboBox2")
For C = 0 To UBound(arrPflicht)
If Me.Controls(arrPflicht(C)) = "" Then
MsgBox "Achtung Pflichtfeld! Bitte alles ausfüllen!"
Me.Controls(arrPflicht(C)).SetFocus
Exit Sub
End If
Next
z = Range("B1").End(xlDown).Row + 1
If z > 65000 Then z = 2
Cells(z, 1) = ComboBox1
Cells(z, 2) = TextBox1
Cells(z, 3) = TextBox2
Cells(z, 4) = TextBox3
Cells(z, 5) = TextBox4
Cells(z, 6) = TextBox5
Cells(z, 7) = CDbl(TextBox6)
Cells(z, 8) = TextBox7
Cells(z, 9) = CDbl(TextBox8)
Cells(z, 10) = TextBox9
Cells(z, 11) = CDate(TextBox10)
Cells(z, 12) = TextBox11
Cells(z, 13) = TextBox12
Cells(z, 14) = TextBox13
Cells(z, 15) = CDate(TextBox14)
Cells(z, 16) = CheckBox1
Cells(z, 17) = ComboBox2
Cells(z, 18) = OptionButton1
Cells(z, 19) = OptionButton2
Cells(z, 20) = TextBox15
If CheckBox1 = True Then
Cells(z, 16) = "X"
End If
If OptionButton1 = Wahr Then
Cells(z, 18) = "X"
Else
Cells(z, 18) = ""
End If
If OptionButton1 = Falsch Then
Cells(z, 18) = ""
Else
Cells(z, 18) = "X"
End If
If OptionButton2 = Wahr Then
Cells(z, 19) = "X"
Else
Cells(z, 19) = ""
End If
If OptionButton2 = Falsch Then
Cells(z, 19) = ""
Else
Cells(z, 19) = "X"
End If
ComboBox1 = ""
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox10 = ""
TextBox11 = ""
TextBox12 = "1"
TextBox13 = ""
TextBox14 = ""
TextBox15 = ""
ChekBox1 = ""
ComboBox2 = ""
End Sub

Anzeige
AW: Sub unterbrechen und fortsetzen
14.01.2004 14:28:21
Slimfast
Super
Vielen Dank
Gruß Slimfast
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige