Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ali ali is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining user access (via user id) using macros maruko Excel Discussion (Misc queries) 0 July 27th 09 02:44 AM
Can a user select more than one entry in a drop down list? Brendan Excel Worksheet Functions 1 July 6th 06 04:40 AM
allow user to select folder jbhoop Excel Discussion (Misc queries) 3 January 3rd 06 10:10 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 06:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"