+ Reply to Thread
Results 1 to 22 of 22

Listbox items display briefly, then disappear?

  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Listbox items display briefly, then disappear?

    I have a list box that displays different regions on a user form. When I load the user form and click on an item in the list box, the selected item is briefly highlighted and then disappears? The items in the list box are linked to a cell and calculations are done based on the selection. The numbers are therefore briefly displayed and then disappear. I am not sure if a property value relating to the list box is causing this?
    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    I had the Calculation Options set to : Automatic, except for data tables. When I changed this setting to Automatic, the list box selections worked.

  3. #3
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    I am still experiencing this problem especially when I open the workbook. Once I navigate to another sheet and return to the problem sheet, the problem disappears? Is there a problem with the following code?
    Please Login or Register  to view this content.
    Thanks in advance

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

    Re: Listbox items display briefly, then disappear?

    How is the listbox populated?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    In the Row Source of the Properties section, I have PrincipalList which is a range name in the workbook.

  6. #6
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    I deleted PrincipalList from Row Source and put the following code in but have a problem with line 5?

    Please Login or Register  to view this content.

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

    Re: Listbox items display briefly, then disappear?

    What is the 'problem'?

    Also how is PrincipalList defined?

  8. #8
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    The List box is not populated. PrincipalList is a range name. Is it wrong to use row source?

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

    Re: Listbox items display briefly, then disappear?

    So do you get an error message?

    One thing for sure is you can't use RowSource and List, use one or the other - List is probably preferable.

  10. #10
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    Run-time error 1004: Invalid number of arguments is the error message?

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

    Re: Listbox items display briefly, then disappear?

    That's because it should be Application.Transpose(Range(...)).

    Even that might not work.

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  12. #12
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    I have created a sample file that behaves similar to my real data. Sometimes when you open the file, Excel closes and other times it opens fine.
    Thanks in advance.
    Attached Files Attached Files

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

    Re: Listbox items display briefly, then disappear?

    Sorry I can't see, or replicate, any error.

    The listboxes appear to populate OK.

    The only weird things seems to be that when select something in the listbox on UserForm2 it doesn't get highlighted properly.

  14. #14
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    Thanks very much for your time & effort Norie. The fact that listbox1 on userform2 only highlights briefly is one of the problems I can't figure out? You have to navigate to another sheet and then return to that sheet in order for a selected item on the list box to remain highlighted and for the formulas to update & Excel crashes when you attempt to select an item on listbox1 from userform2? Sometimes Excel crashes when you open the file and other times it opens & works fine? I would really like to understand why this happens? I hope someone can figure this out?
    Thanks in advance.

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

    Re: Listbox items display briefly, then disappear?

    I couldn't get that to happen, but I can take a guess on why it's happening.

    It could be because you are using the same ControlSource for the customer listbox on each form.

    Using ControlSource is kinf a bad idea in the first place but to have 2 listboxes with the same range as the ControlSource, well that's kind of twice as bad.

    You could easily write a few lines of code to put the selection from the listbox(es) on the worksheet.

    This should be all you need for each listbox.
    Please Login or Register  to view this content.
    I notice you are also using ControlSource for the month listbox, you could use similar code to put it's selected value on the sheet.

    If you do want to change to using code, and I would recommend you do, remember to clear out the ControlSource property of each listbox.

    By the way, it might be a good idea to display the month and customer somewhere on the sheet with the table/chart.

    Otherwise it's not clear, or it wasn't to me anyway, which month/customer the table and chart are for.

  16. #16
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    Once again, thanks very much for your assistance. I used code as per your suggestion and removed the ControlSource property and the problem has disappeared! The only other thing I would like to do is if I select a customer on DashboardOne and then go to DashBoardTwo, I would like the same customer I was viewing on DashboardOne to be highlighted rather than scrolling down to find that customer. I thought the following code would work but it doesn't?
    Please Login or Register  to view this content.
    Thanks in advance.

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

    Re: Listbox items display briefly, then disappear?

    Where did you put the code?

  18. #18
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    I put the code in the list box as follows:

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    Sorry, I presume you meant the other code. It is in a module:
    Please Login or Register  to view this content.

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

    Re: Listbox items display briefly, then disappear?

    You're trying to get the value from UserForm1 after it's been unloaded.

    Try this.
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Listbox items display briefly, then disappear?

    Thanks Norie. Everything is working fine now. This is the code I used:

    Please Login or Register  to view this content.

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

    Re: Listbox items display briefly, then disappear?

    I probably would have used ListIndex myself, but you used Value in your original code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Making a command button and listbox disappear after use
    By benochs1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2013, 12:53 PM
  2. [SOLVED] Auto select items in a Listbox with items from another Listbox
    By perducci in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-22-2013, 04:45 PM
  3. Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox
    By muneebmansoor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2013, 02:21 PM
  4. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  5. [SOLVED] How to display Items in ListBox
    By sam in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2006, 09:50 AM

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