Thread: Numbers
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Numbers

Greg,
Try the following which assumes there are 30 different macros
called macro1 to macro30.

Private Sub ListBox1_Click()
Application.Run "macro" & ListBox1.Value
End Sub

An alternative is to use the Case statement

Select Case Listbox1.value
Case is=1
Call FirstMacro
Case is=2
Call SecondMacro
........
End Select

If the same macro is called for several listbox numbers, these can be
combined in the case statement e.g.

Case is = 3 ,7,15
Call MacroX


HTH

"Greg" wrote:

Hi all,

I have a list box that has the numbers 1 - 30 in this list. I would like to
have a particular macro run for each individual number.

How do I get a macro to run for a certain number using a listbox, or should
I be using something else?

Thanks

Greg