Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
List macros for user to select...
Hi,
I am trying to create a macro that will bring up a list of 4 macros allowing the user to select one of them from the list. On clicking o the macro is run. Unfortunately i am at a complete loss as to how to do this. Can anyon please help with this? Also, is it possible to allow the user to select more than one macr and on clicking ok the macros are run (macro 1 first, followed by macr 2) Many thanks for your help on this topi -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
List macros for user to select...
ali, the macro below will debug.print a list of macros and which module
they are found in. You can use this list to populate a combobox (I assume that you already know how to do that, right?) Sub CreateListofMacros() Attribute Macro2.VB_Description = "12/28/03 by Pete" Attribute Macro2.VB_ProcData.VB_Invoke_Func = " \n14" ' ' Macro2 Macro ' Dim startLine As Long, LastLine As Long, startcol As Long Set thisProject = Application.VBE.ActiveVBProject LineCount = Application.VBE.CodePanes(2).CodeModule.CountOfLin es 'thiscomponent = Application.VBE.ActiveVBProject.VBComponents(6).Na me For Each Pane In Application.VBE.CodePanes startLine = 1 startcol = 1 LastLine = Pane.CodeModule.CountOfLines SubHere = Pane.CodeModule.Find("Sub", startLine, startcol, 2000, 1, False, False) Do While startLine < LastLine thisSub = Pane.CodeModule.procofline(startLine, 1) If thisSub < thatSub Then Debug.Print thisSub & " is found in " & Pane.CodeModule.Name thatSub = thisSub End If 'On Error Resume Next startLine = startLine + 1 Loop Next Pane 'VBAProject.Test.CreateListofMacros End Sub --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
List macros for user to select...
Create a userform (UserForm1) with a Listbox (ListBox1) and a button
(CommandButton1) In the userform code area, paste in: Private Sub CommandButton1_Click() Dim i As Integer With Me.ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then Application.Run .List(i, 0) End If Next i End With End Sub Private Sub UserForm_Initialize() With Me.ListBox1 .AddItem "Macro1" .AddItem "Macro2" .AddItem "Macro3" .AddItem "Macro4" End With End Sub change the macro names to suit. "ali" wrote in message ... Hi, I am trying to create a macro that will bring up a list of 4 macros, allowing the user to select one of them from the list. On clicking ok the macro is run. Unfortunately i am at a complete loss as to how to do this. Can anyone please help with this? Also, is it possible to allow the user to select more than one macro and on clicking ok the macros are run (macro 1 first, followed by macro 2) Many thanks for your help on this topic --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
List macros for user to select...
Have you considered using ALT+F8 for macros in an open workbook (not in
an add-in)? -- Regards, Tushar Mehta, MS MVP -- Excel www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , ali.z5kaa@excelforum- nospam.com says... Hi, I am trying to create a macro that will bring up a list of 4 macros, allowing the user to select one of them from the list. On clicking ok the macro is run. Unfortunately i am at a complete loss as to how to do this. Can anyone please help with this? Also, is it possible to allow the user to select more than one macro and on clicking ok the macros are run (macro 1 first, followed by macro 2) Many thanks for your help on this topic --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Defining user access (via user id) using macros | Excel Discussion (Misc queries) | |||
Can a user select more than one entry in a drop down list? | Excel Worksheet Functions | |||
allow user to select folder | Excel Discussion (Misc queries) | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming |