Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1396to1400
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
Inhaltsverzeichnis

Mit Esc Abbrechen

Mit Esc Abbrechen
22.12.2014 15:39:56
Vulferin
Hi Zusammen
ich habe diesen Ablauf um einen neuen Eintrag zu erstellen
Es kommt es in der Praktzis vor das wir versehendlich auf den Knopf drücken.
Wie kann ich das mit ESC abbruch bar machen ?
HIer mein Code
  • 
    Private Sub CommandButton1_Click()
    Windows("Tüv Mangel").Activate
    Call showallsuche
    Dim lngErsteFreie As Long
    Dim intSpalte As Integer
    Dim i As Integer
    If CommandButton1.Caption = "Neuer Eintrag" Then
    For i = 1 To 9
    Controls("Textbox" & i) = ""
    Next
    TextBox11 = ""
    TextBox13 = ""
    TextBox15 = ""
    For i = 17 To 21
    Controls("Textbox" & i) = ""
    Next
    TextBox31 = ""
    TextBox34 = ""
    TextBox35 = ""
    TextBox36 = ""
    ComboBox3 = ""
    ComboBox4 = ""
    For i = 1 To 4
    Controls("Checkbox" & i) = False
    TextBox3.SetFocus
    Next
    CommandButton1.Caption = "Neuer Eintrag Speichern"
    CommandButton1.Enabled = False
    CommandButton2.Visible = False
    CommandButton3.Visible = False
    CommandButton4.Visible = False
    CommandButton10.Visible = False
    CheckBox5.Value = True
    ToggleButton1.Visible = False
    ToggleButton2.Visible = False
    ToggleButton3.Visible = False
    ToggleButton4.Visible = False
    ToggleButton5.Visible = False
    ToggleButton6.Visible = False
    Else
    lngErsteFreie = Cells(Rows.Count, "A").End(xlUp).Row + 1
    For intSpalte = 1 To 6
    Cells(lngErsteFreie, intSpalte).Value = Controls("TextBox" & intSpalte)
    Next
    Cells(lngErsteFreie, 7).Value = ComboBox4.Value
    Call prcFill_SpalteH(ZelleZiel:=Tabelle1.Cells(lngErsteFreie, 8), _
    varTextbox:=TextBox8.Value)
    Cells(lngErsteFreie, 9).Value = TextBox9
    Cells(lngErsteFreie, 10).Value = CheckBox1
    Cells(lngErsteFreie, 11).Value = TextBox11
    Cells(lngErsteFreie, 12).Value = CheckBox2
    Cells(lngErsteFreie, 13).Value = TextBox13
    Cells(lngErsteFreie, 14).Value = CheckBox3
    Cells(lngErsteFreie, 15).Value = TextBox15
    Cells(lngErsteFreie, 16).Value = CheckBox4
    For intSpalte = 17 To 21
    Cells(lngErsteFreie, intSpalte).Value = Controls("TextBox" & intSpalte)
    Next
    Cells(lngErsteFreie, 22).Value = TextBox31
    Cells(lngErsteFreie, 23).Value = TextBox32
    Cells(lngErsteFreie, 24).Value = TextBox34
    Cells(lngErsteFreie, 25).Value = ComboBox3.Value
    Cells(lngErsteFreie, 26).Value = TextBox35
    Cells(lngErsteFreie, 27).Value = TextBox36
    Call Zuruecksetzen
    Call UserForm_Initialize
    End If
    End Sub
    

  • 1
    Beitrag zum Forumthread
    Beitrag zu diesem Forumthread

    Betreff
    Datum
    Anwender
    Anzeige
    Mach doch eine Sicherheitsabfrage zum Starten
    22.12.2014 16:00:34
    Matthias
    Hallo
    Mal ein Vorschlag
    Nicht abbrechen, sondern einfach vorher nachfragen ob das Prgr. wirklich starten soll.
    Option Explicit
    Private Sub CommandButton1_Click()
    If MsgBox("Haben Sie mit Absicht den Knopf gedrückt" & vbLf & "Soll das Programm jetzt  _
    gestartet werden", vbYesNo + vbDefaultButton2) = vbYes Then
    '        Windows("Tüv Mangel").Activate
    '        Call showallsuche
    '        Dim lngErsteFreie As Long
    '        Dim intSpalte As Integer
    '        Dim i As Integer
    '        If CommandButton1.Caption = "Neuer Eintrag" Then
    '            For i = 1 To 9
    '                Controls("Textbox" & i) = ""
    '            Next
    '            TextBox11 = ""
    '            TextBox13 = ""
    '            TextBox15 = ""
    '            For i = 17 To 21
    '                Controls("Textbox" & i) = ""
    '            Next
    '            TextBox31 = ""
    '            TextBox34 = ""
    '            TextBox35 = ""
    '            TextBox36 = ""
    '            ComboBox3 = ""
    '            ComboBox4 = ""
    '            For i = 1 To 4
    '                Controls("Checkbox" & i) = False
    '            TextBox3.SetFocus
    '            Next
    '            CommandButton1.Caption = "Neuer Eintrag Speichern"
    '            CommandButton1.Enabled = False
    '            CommandButton2.Visible = False
    '            CommandButton3.Visible = False
    '            CommandButton4.Visible = False
    '            CommandButton10.Visible = False
    '            CheckBox5.Value = True
    '            ToggleButton1.Visible = False
    '            ToggleButton2.Visible = False
    '            ToggleButton3.Visible = False
    '            ToggleButton4.Visible = False
    '            ToggleButton5.Visible = False
    '            ToggleButton6.Visible = False
    '        Else
    '            lngErsteFreie = Cells(Rows.Count, "A").End(xlUp).Row + 1
    '            For intSpalte = 1 To 6
    '                Cells(lngErsteFreie, intSpalte).Value = Controls("TextBox" & intSpalte)
    '            Next
    '            Cells(lngErsteFreie, 7).Value = ComboBox4.Value
    '            Call prcFill_SpalteH(ZelleZiel:=Tabelle1.Cells(lngErsteFreie, 8), _
    '            varTextbox:=TextBox8.Value)
    '            Cells(lngErsteFreie, 9).Value = TextBox9
    '            Cells(lngErsteFreie, 10).Value = CheckBox1
    '            Cells(lngErsteFreie, 11).Value = TextBox11
    '            Cells(lngErsteFreie, 12).Value = CheckBox2
    '            Cells(lngErsteFreie, 13).Value = TextBox13
    '            Cells(lngErsteFreie, 14).Value = CheckBox3
    '            Cells(lngErsteFreie, 15).Value = TextBox15
    '            Cells(lngErsteFreie, 16).Value = CheckBox4
    '            For intSpalte = 17 To 21
    '                Cells(lngErsteFreie, intSpalte).Value = Controls("TextBox" & intSpalte)
    '            Next
    '            Cells(lngErsteFreie, 22).Value = TextBox31
    '            Cells(lngErsteFreie, 23).Value = TextBox32
    '            Cells(lngErsteFreie, 24).Value = TextBox34
    '            Cells(lngErsteFreie, 25).Value = ComboBox3.Value
    '            Cells(lngErsteFreie, 26).Value = TextBox35
    '            Cells(lngErsteFreie, 27).Value = TextBox36
    '            Call Zuruecksetzen
    '        Call UserForm_Initialize
    '    End If
    Else
    MsgBox "Danke für diese Abfrage ;-)", vbInformation
    End If
    End Sub
    
    Gruß Matthias
    Anzeige

    Links zu Excel-Dialogen

    Beliebteste Forumthreads (12 Monate)

    Anzeige

    Beliebteste Forumthreads (12 Monate)

    Anzeige
    Anzeige
    Anzeige