AW: Makro bzw. Modul in Forms als Dropdown einbinden
20.04.2015 19:32:26
Nepumuk
Hallo,
folgender Code in ein Standardmodul:
Option Explicit
Public Sub ProcedurList()
Dim lngLine As Long
Dim strProcedurName As String, strTempProcedurName As String
Dim strValiationText As String
With ThisWorkbook.VBProject.VBComponents("Modul1").CodeModule 'Modulname anpassen
For lngLine = 1 To .CountOfLines
If .ProcOfLine(lngLine, 0) <> "" Then
strProcedurName = .ProcOfLine(lngLine, 0)
If strProcedurName <> strTempProcedurName Then
strTempProcedurName = strProcedurName
strValiationText = "," & strValiationText & strProcedurName
End If
End If
Next
End With
strValiationText = Mid$(strValiationText, 2)
With Cells(1, 1).Validation 'Zelle anpassen
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=strValiationText
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub
Den folgenden Code in die Tabelle mit in der das Dropdown angezeigt werden soll.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then If Not IsEmpty(Target.Value) Then _
Call Application.Run(Target.Text)
End Sub
Anpassen kannst du das sicher selbst.
Gruß
Nepumuk