If I load it from this forum (into the browser, or into Excel) no problem arises.
You can save the file first on your computer/ open Excel/ open the workbook.
code in the class-module
Public WithEvents mCombo As MSForms.ComboBox Private Sub mCombo_Change() MsgBox "You changed " & mCombo.Name End Sub
code in the Workbook-module
Public col_Events As New Collection Sub Workbook_Open() For Each ctl In Sheets(1).OLEObjects If LCase(TypeName(ctl.Object)) = "combobox" Then ctl.Object.List = Array("A", "B", "C") col_Events.Add New clsActiveXevents Set col_Events(col_Events.Count).mCombo = ctl.Object End If Next End Sub
I am still unable to open it even with Excel open first.
Anyway thank you for posting the code. The List command is much better and usefull than the AddItem !![]()
Hi oro77
I only included the ActiveX code so you could see how it could be done; I still recommend (as per post #2) that you to use the Forms controls because they are more reliable and (clearly) simpler to implement!Sure, they're lightweight so there are some things you can't do with them that you can do with their ActiveX equivalents but, if you need something fancier than the Forms controls can do, then you should probably be using a userform, not a worksheet.
Btw, you'll notice that the ActiveX code I posted deliberately avoids the use of Public variables in the class modules: I declared them with Private scope and exposed them using properties ('getters', 'letters' and 'setters').
@snb
Are you referring to AfterUpdate, BeforeUpdate, Enter and Exit?Originally Posted by snb
Hello Colin Legg
Thanks for your comments.
I also thought about using a userform but I don't know how many combo box will be needed, it is kind of dynamic and I am afraid that by using userform, I may not need have enough space to place them all.
I guess the useform size could be dynamic too but if it becomes too large, it would be bad :P
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks