+ Reply to Thread
Results 1 to 12 of 12

VBA Userfrom problem - easy solve

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Question VBA Userfrom problem - easy solve

    Hi there,

    Can anyone tell me what is wrong with this code? It is drawing it's data from a query table in a sheet called "sheet3". When i run the userform, the listbox just comes up as blank. Can anyone help?

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userfrom problem - easy solve

    How are you loading the userform and what is the value of the ActiveCell? If it has a value, is it uppercase?

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    It's Userform_Initialize not Userform1_Initialize.

    The latter will never run, so the listbox will never be populated.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: VBA Userfrom problem - easy solve

    Thanks for the reply.

    Basically it's a load of numbers, up to 5 digits long. I am loading the userform from a form button, and then unloading it when I double-click an entry in the listbox. The entry I double-click then goes through to the Active Cell.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userfrom problem - easy solve

    Ok, I think you want:
    Please Login or Register  to view this content.
    Last edited by Kyle123; 07-04-2013 at 03:58 AM.

  6. #6
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: VBA Userfrom problem - easy solve

    Excellent, that works. The only trouble is, I have a Vlookup working off that cell, and it doesn't work. The reason is because in the query table, the numbers are "numbers stored as text", whereas the numbers that the userform puts into the cell are just numbers. Therefore the Vlookup views them as something different, bringing through N/A instead of the stuff I need.

    Any ideas?

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userfrom problem - easy solve

    I've changed my code to input the number as text

  8. #8
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: VBA Userfrom problem - easy solve

    OK thanks Kyle. Your code has the same problem, in that the Listbox is blank. When I used my previous code and replaced Userform1_Initialize with Userform_Initialize, it worked fine. Is there anyway I can edit my previous code to enter a number stored as text? Or to somehow get your code working?

    Thanks very much. Appreciate it.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userfrom problem - easy solve

    Can you upload a small sample workbook? your code is horrifically slow , mine is much faster, so if you can upload some sample data I'll see if I can fix it

  10. #10
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: VBA Userfrom problem - easy solve

    OK here goes Excel Forum.xlsm

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA Userfrom problem - easy solve

    Ah, I'd changed my code since that version, try it now...

  12. #12
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: VBA Userfrom problem - easy solve

    Excellent - that has sorted it. Thanks very much for your time.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1