LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Userform combo box triggering macros

Dave,
Absolutely PERFECT advice. Thanks again.
Dave Peterson wrote:
That's the way I initialized the combobox. Did you use a range that held 1-10?

You could drop that portion and use the .rowsource you used before--or you could
drop the rowsource (manually in design mode) or even set things up in code:

Private Sub UserForm_Initialize()
Dim iCtr As Long
Me.ComboBox1.RowSource = ""
Me.ComboBox1.Clear
For iCtr = 1 To 10
Me.ComboBox1.AddItem iCtr
Next iCtr
End Sub



michaelberrier wrote:

Dave,
works well except for this:

Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.ComboBox1.AddItem iCtr
Next iCtr
End Sub

With this in the userform code module, I cannot show the userform, it
says "Permission Denied".
?
Thanks.

Dave Peterson wrote:
I put these in a general module:
Option Explicit
Sub MakeMan1()
MsgBox "hi from 1"
End Sub
Sub MakeMan2()
MsgBox "hi from 2"
End Sub
Sub MakeMan3()
MsgBox "hi from 3"
End Sub
Sub MakeMan4()
MsgBox "hi from 4"
End Sub
Sub MakeMan5()
MsgBox "hi from 5"
End Sub
Sub MakeMan6()
MsgBox "hi from 6"
End Sub
Sub MakeMan7()
MsgBox "hi from 7"
End Sub
Sub MakeMan8()
MsgBox "hi from 8"
End Sub
Sub MakeMan9()
MsgBox "hi from 9"
End Sub
Sub MakeMan10()
MsgBox "hi from 10"
End Sub

I put this behind the userform:

Option Explicit
Private Sub ComboBox1_Change()
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
Else
Application.Run "MakeMan" & Me.ComboBox1.ListIndex + 1
End If
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.ComboBox1.AddItem iCtr
Next iCtr
End Sub


And it worked ok for me.

Just a thought...

As a user, I often screw up and choose the wrong item from a
listbox/combobox/checkbox/optionbutton, well every control there is! I think
I'd want to see an Ok button that does the real work--instead of using the
_click event.

But that's just me...

michaelberrier wrote:

I'm using a UserForm with a Combo Box that displays the numbers 1-10 as
choices. I need a different macro to fire based on whatever number is
selected. I've tried many of the solutions offered by previous posts,
but I can't make it work. i.e.: Should the user select "1", then the
macro "makeman1" will execute and so forth through "10".

Thanks in advance. Please be specific in any reply about how the
syntax should be.

--

Dave Peterson


--

Dave Peterson


 
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
Can a combo box activate different macros Carrie Excel Discussion (Misc queries) 1 June 5th 06 06:34 PM
Macro that can run combo boxes simonsmith Excel Discussion (Misc queries) 0 June 5th 06 05:00 PM
Help with combo boxes and macros in Excel 2003 Carrie Excel Discussion (Misc queries) 3 May 18th 06 08:24 PM
Nesting Combo Boxes /Returning an Array ELMONDO SNITHER Excel Discussion (Misc queries) 1 June 30th 05 01:15 AM
UserForm and combo box to another sheet Nigel Excel Discussion (Misc queries) 0 April 29th 05 09:41 AM


All times are GMT +1. The time now is 02:08 AM.

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

About Us

"It's about Microsoft Excel"