Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Enden

Forumthread: Enden

Enden
serge
Hallo leute
Mit folgendem Makro rufe ich ein Formular auf
Sub commandbutton()
Sadresse = Selection.Address(RowAbsolute:=False, columnAbsolute:=False)
If Application.CountA(Range(Sadresse)) > 0 Then
MsgBox ("In der ausgwählten Zeitspanne besteht schon ein Termin!")
Else
Dim wahl
ActiveSheet.Unprotect Password:="smart"
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Sadresse = Selection.Address(RowAbsolute:=False, columnAbsolute:=False)
wahl = MsgBox("Wollen Sie im ausgewähltem Bereich " & vbCrLf & vbCrLf & " " & Selection.Address(RowAbsolute:=False, columnAbsolute:=False) & " " & vbCrLf & vbCrLf & " einen Termin festlegen?", vbYesNo, "Termin einfügen!")
Application.ScreenUpdating = True
If wahl = vbYes Then
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
Übersicht.Show ActiveSheet.Protect Password:="smart", DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Labtopbeamer").Select
Range(Sadresse).Select
CommandButtonpc
Else
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
ActiveSheet.Protect Password:="smart", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
End Sub
wenn ich nun dieses Formular abbrech mit:

Private Sub CommandButton3_Click()
Application.EnableEvents = False
Unload Me
Application.EnableEvents = True
End Sub

möchte ich das Makro Sub commandbutton() auch abbrechen!
Wie stelle ich das an?
Im jetzigen Zustand geht mein markro bie
Contents:=True, Scenarios:=True
weiter
danke Serge
Anzeige

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Enden
06.11.2009 12:29:00
xr8k2
Hallo Serge,
ich würd´s evtl mit einer globalen Variable machen ...

Dim Abbr as boolean
Sub commandbutton()
Sadresse = Selection.Address(RowAbsolute:=False, columnAbsolute:=False)
If Application.CountA(Range(Sadresse)) > 0 Then
MsgBox ("In der ausgwählten Zeitspanne besteht schon ein Termin!")
Else
Dim wahl
ActiveSheet.Unprotect Password:="smart"
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Sadresse = Selection.Address(RowAbsolute:=False, columnAbsolute:=False)
wahl = MsgBox("Wollen Sie im ausgewähltem Bereich " & vbCrLf & vbCrLf & " " & Selection.Address( _
RowAbsolute:=False, columnAbsolute:=False) & " " & vbCrLf & vbCrLf & " einen Termin festlegen?", vbYesNo, "Termin einfügen!")
Application.ScreenUpdating = True
If wahl = vbYes Then
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
Übersicht.Show
if abbr then exit sub
ActiveSheet.Protect Password:="smart", DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Labtopbeamer").Select
Range(Sadresse).Select
CommandButtonpc
Else
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
ActiveSheet.Protect Password:="smart", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
End Sub
Private Sub CommandButton3_Click()
abbr = true
Application.EnableEvents = False
Unload Me
Application.EnableEvents = True
End Sub

Gruß,
xr8k2
Anzeige
AW: Enden
06.11.2009 12:29:44
Rudi
Hallo,
1. definiere eine Public-Variable
Public blnCancel as Boolean
2.
Private Sub CommandButton3_Click()
Application.EnableEvents = False
blnCancel=True
Unload Me
Application.EnableEvents = True
End Sub

3.
........
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
Übersicht.Show
If blnCancel Then
blnCancel=False
Exit Sub
End If

ActiveSheet.Protect Password:="smart", DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Labtopbeamer").Select
Range(Sadresse).Select
CommandButtonpc
.......
Gruß
Rudi
Anzeige
Danke an beide, es klappt! owT
06.11.2009 17:01:58
serge
;

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