Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1560to1564
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
Prüfen ob CommandButton vorhanden ist
07.06.2017 11:46:05
philipp
Guten Tag zusammen,
ich würde gern prüfen ob ein CommandButton vorhanden ist,
leider nicht soviel Ahnung.
mfg
philipp b

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Prüfen ob CommandButton vorhanden ist
07.06.2017 11:52:26
Max2
Hallo,
so:
Dim ctl As Control
Dim sh As Shape
'In UserForm
For Each ctl In UserForm1.Controls
If ctl.Name = "Name der ComboBox" Then
..code
Exit For
End If
Next ctl
'Auf Worksheet
For Each sh In ActiveSheet.Shapes
If sh.Name = "Name der ComboBox" Then
..code
Exit For
End If
Next sh 

Makro läuft...
07.06.2017 12:15:08
philipp
Hallo Max,
danke für die schnelle Hilfe.
Habe so eingesetzt:
For Each sh In ActiveSheet.Shapes
If sh.Name = "CommandButton2" Then
MsgBox "vorhanden"
Exit For
Else
MsgBox "nicht da"
End If
Next sh
Makro läuft immer weiter, mußte mit ESC abbrechen.
Ich möchte dies nur für die active Sheet .
mfg
philipp b
Anzeige
AW: Makro läuft...
07.06.2017 12:22:56
Rudi
Hallo,
Sub aaa()
Dim sh As Shape, bol As Boolean
For Each sh In ActiveSheet.Shapes
If sh.Name = "CommandButton2" Then bol = True
Next
If bol Then
MsgBox "vorhanden"
Else
MsgBox "nicht da"
End If
End Sub
Gruß
Rudi
Korrektur
07.06.2017 12:24:23
Rudi

Sub aaa()
Dim sh As Shape, bol As Boolean
For Each sh In ActiveSheet.Shapes
If sh.Name = "CommandButton2" Then
bol = True
Exit For
Next
If bol Then
MsgBox "vorhanden"
Else
MsgBox "nicht da"
End If
End Sub

Rudi das 1. Beispiel funktioniert aber..
07.06.2017 13:37:54
philipp
Hallo Rudi,
das 1. Beispiel einwandfrei bei der Korrektor bleibt bei
Next stehen. Meldung: ohne Next ohne For
mfg
philipp b
Anzeige
AW: Rudi das 1. Beispiel funktioniert aber..
07.06.2017 14:03:08
dirk
Hallo!
Sub aaa()
Dim sh As Shape, bol As Boolean
For Each sh In ActiveSheet.Shapes
If sh.Name = "CommandButton2" Then
bol = True
Exit For
end if
Next
If bol Then
MsgBox "vorhanden"
Else
MsgBox "nicht da"
End If
End Sub
Gruss
Dirk aus Dubai
Alles klappt DANKE an Alle ! -)
07.06.2017 14:39:51
philipp

311 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige