Consulting

Results 1 to 7 of 7

Thread: Solved: Class Modules and UserForm_Initialize

  1. #1
    VBAX Regular
    Joined
    Sep 2008
    Location
    Wyoming
    Posts
    41
    Location

    Solved: Class Modules and UserForm_Initialize

    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
    [VBA]
    Sub UserForm_Initialize()
    Set exlStuff = New clsExlData.
    End Sub
    [/VBA]

    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

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    [vba]
    Private Sub UserForm_Initialize()
    Set exlStuff = New clsExlData
    exlStuff.clsExlShts
    End Sub
    [/vba]

    I am moving this to the correct forum.

    EDIT: Added note and moved to Word Forum. Tommy

  3. #3
    VBAX Regular
    Joined
    Sep 2008
    Location
    Wyoming
    Posts
    41
    Location
    Hmm, added the information in and the combo boxes still won't populate. I also tried this...
    [VBA]
    Private Sub UserForm_Initialize()
    Dim exlStuff As New clsExlData
    Set exlStuff = New clsExlData
    exlStuff.clsExlShts
    [/VBA]

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

  4. #4
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Is the spreadsheet still located at : "C:\Documents and Settings\MPHILL\Desktop\General_List.xlsx"

    You are not adding these items.
    [VBA]
    cboPerson.List = exlSheetNames.Range("A2:A" & EmptyRow - 1).Value
    [/VBA]

    You will need to do
    [VBA]
    cboPerson.AddItem exlSheetNames.Range("A2").Value
    [/VBA]
    until the whole range has been added to the combo box.

  5. #5
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Anothe thing is you may need to fully qualify the combo boxes, as in:
    [VBA]frmInput.cboPerson.List = exlSheetNames.Range("A2:A" & EmptyRow - 1).Value [/VBA]
    or
    [VBA]frmInput.cboPerson.AddItem exlSheetNames.Range("A2").Value [/VBA]

  6. #6
    VBAX Regular
    Joined
    Sep 2008
    Location
    Wyoming
    Posts
    41
    Location
    Yes, the spreadsheet is located in the same location. I will give it a try. Thanks!

  7. #7
    VBAX Regular
    Joined
    Sep 2008
    Location
    Wyoming
    Posts
    41
    Location
    Fully qualified, that did it. Makes sense now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •