PDA

View Full Version : Solved: Class Modules and UserForm_Initialize



mphill
12-12-2008, 02:31 PM
Hello Again,

The code in my Sub UserForm_Initialize() works fine and seemed to be a candidate for a Class Module for use in other projects. I created a clsExlData with the copied code and commented the original out in the UserForm_Initialize().

Under the Option Explicit I entered the Private exlStuff as New clsExlData to instantiate the class and in the

Sub UserForm_Initialize()
Set exlStuff = New clsExlData.
End Sub


What will I need to do next to populate the cboPerson in the user form now, since it fails to populate? Will I need Property Get procedures and\or Types set?

I have been looking on the web trying to educate myself on this but still not able to get it to work.

See attached file

Tommy
12-13-2008, 10:53 AM
Private Sub UserForm_Initialize()
Set exlStuff = New clsExlData
exlStuff.clsExlShts
End Sub


I am moving this to the correct forum.

EDIT: Added note and moved to Word Forum. Tommy

mphill
12-15-2008, 08:59 AM
Hmm, added the information in and the combo boxes still won't populate. I also tried this...

Private Sub UserForm_Initialize()
Dim exlStuff As New clsExlData
Set exlStuff = New clsExlData
exlStuff.clsExlShts


I must have something amiss, still. Any other suggestions are appreciated.
Thanks for moving to correct forum, too.:doh:

Tommy
12-15-2008, 09:17 AM
Is the spreadsheet still located at : "C:\Documents and Settings\MPHILL\Desktop\General_List.xlsx"

You are not adding these items.

cboPerson.List = exlSheetNames.Range("A2:A" & EmptyRow - 1).Value


You will need to do

cboPerson.AddItem exlSheetNames.Range("A2").Value

until the whole range has been added to the combo box.

Tommy
12-15-2008, 09:31 AM
Anothe thing is you may need to fully qualify the combo boxes, as in:

frmInput.cboPerson.List = exlSheetNames.Range("A2:A" & EmptyRow - 1).Value
or

frmInput.cboPerson.AddItem exlSheetNames.Range("A2").Value

mphill
12-15-2008, 09:39 AM
Yes, the spreadsheet is located in the same location. I will give it a try. Thanks!

mphill
12-15-2008, 01:40 PM
Fully qualified, that did it. Makes sense now.