Thread: Numbers
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Numbers

a simple method would be to ensure that your sub have similar names eg
MySub01
MySub02
....
MySub31

then you'd just need one line

Call "MySub" & Format$(MyListBox.Value,"00")

Otherwise, the Select Case method is worth trying

SELECT CASE MyListBox.Value
CASE 1,5,8 : Call ThisSUb
CASE 2 : Call ThisOtherSub
CASE 3,12,15: Call YetAnotherSub
CASE ELSE : msgbox "oops !",,"missing sub: " & MyListBox.Value
END SELECT



"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