Thema Datum  Von Nutzer Rating
Antwort
13.12.2016 16:03:16 Julian
NotSolved
13.12.2016 16:10:13 Mackie
NotSolved
Rot Dropdown-Menü
13.12.2016 18:58:13 Gast32718
NotSolved
14.12.2016 13:16:19 Julian
NotSolved
14.12.2016 16:30:10 Mackie
NotSolved
14.12.2016 18:11:56 Gast32718
NotSolved

Ansicht des Beitrags:
Von:
Gast32718
Datum:
13.12.2016 18:58:13
Views:
809
Rating: Antwort:
  Ja
Thema:
Dropdown-Menü

Meinst du DropDown oder Popup?

Das zweite ist etwas kompliziert / bedarf sorgfältige Planung und Ausarbeitung. Grob gesehen könnte es so aussehen:

 

Dieser Code kommt in ein Modul:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Option Explicit
 
Public Function GetDropDown(Sh As Object, ByVal Target As Range, Optional ReInit As Boolean) As CommandBar
   
  Const C_POPUP_NAME As String = "__myMainPopup"
   
  Dim objPopup As CommandBar
   
  For Each objPopup In Application.CommandBars
    If objPopup.Name = C_POPUP_NAME Then Exit For
  Next
   
  If Not objPopup Is Nothing And ReInit Then
    Call objPopup.Delete
    Set objPopup = Nothing
  End If
   
  If objPopup Is Nothing Then
     
    Set objPopup = Application.CommandBars.Add(C_POPUP_NAME, msoBarPopup, , True)
     
    '1. Ebene: 1. Element
    With objPopup.Controls.Add(msoControlComboBox, Temporary:=True)
      .OnAction = "Popup_OnAction"
      .Caption = "Item1-1"
      .Tag = "cboSelection1"
      Call .AddItem("SubItem1")
      Call .AddItem("SubItem2")
      Call .AddItem("SubItem3")
    End With
    '1. Ebene: 2. Element
    With objPopup.Controls.Add(msoControlButton, Temporary:=True)
      .OnAction = "Popup_OnAction"
      .Caption = "Item1-2"
      .Tag = "btnAction1"
    End With
     
    '1. Ebene: 3. Element
    With objPopup.Controls.Add(msoControlPopup, Temporary:=True)
      .Caption = "Item1-3"
      .Tag = "mnuSub1"
      '2. Ebene: 1. Element
      With .Controls
        With .Add(msoControlButton, Temporary:=True)
          .OnAction = "Popup_OnAction"
          .Caption = "Item1-3-1"
          .Tag = "btnAction1-1"
        End With
      End With
    End With
     
  End If
   
  Set GetDropDown = objPopup
   
End Function
 
Public Sub Popup_OnAction()
  With CommandBars.ActionControl
    If .Type = msoControlComboBox Then
      MsgBox .Tag & " { Text = '" & .Text & "' }"
    Else
      MsgBox .Tag
    End If
  End With
End Sub

 

Dieser Code kommt in DieseArbeitsmape:

1
2
3
4
5
6
7
8
Option Explicit
 
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
   
  Cancel = True
  GetDropDown(Sh, Target, True).ShowPopup
   
End Sub

Wenn du jetzt auf ein beliebiges Tabellenblatt klickst, erhält man soetwas:

 

Gruß

 

PS: Wohl am besten / saubersten wäre es, wenn man das in Klassen programmiert.


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
13.12.2016 16:03:16 Julian
NotSolved
13.12.2016 16:10:13 Mackie
NotSolved
Rot Dropdown-Menü
13.12.2016 18:58:13 Gast32718
NotSolved
14.12.2016 13:16:19 Julian
NotSolved
14.12.2016 16:30:10 Mackie
NotSolved
14.12.2016 18:11:56 Gast32718
NotSolved