+ Reply to Thread
Results 1 to 10 of 10

Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

Hybrid View

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Unhappy Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Hi Everyone,

    I'm stumped by a very weird Excel issue. Consider this sample scenario:

    I have a simple listbox with 3 items in it. I double click on any of the three items, a message box pops up and I click OK. Now, Excel practically freezes (I can't click on any other control neither can I click the red cross to close the user form, can't use VBA either) UNLESS I move mouse pointer over the same listbox.

    Attached is this sample scenario.

    Could someone please help me out in figuring out the issue?

    Thank you!

    I asked the same question at http://www.ozgrid.com/forum/showthre...610#post651610

    listboxissue.xlsm

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

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    What is this code meant to do?
        With lbValidation
            strRowSource = .RowSource
            .RowSource = vbNullString
            .RowSource = strRowSource
        End With
    Without it everything works fine.

    Perhaps the problem is because you are using the RowSource property which is a kind of 2 way thing between the worksheet and listbox.

    Why not populate the listbox like this?
       lbValidation.List = Range(sRowsource).Value
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Like I said this is a sample scenario. In the actual case, when a user double clicks on a value in Listbox, an input box pops in which user enters a value. This value is then written to a sheet and listbox is updated automatically since it has a static rowsource (I do not change the rowsource in this case).

    I also noticed something that as long as listbox.listindex stays at 0 (if the first value is double-clicked), it works fine. But I also tried to force the listindex to 0 after writing the value to the sheet but once it goes to -1, it freezes everything.

  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: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Using RowSource is not a good idea, and this is the sort of thing that can happen when you do.

    If you populate as I suggest it's straightforward to write a line (maybe two) of code to put the user entered value on the sheet and update the listbox.

  5. #5
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Will this also work when I have multiple columns in the listbox?

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

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Yes, though obviously there could be a few more lines of code.

  7. #7
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Range("refLookups!$A$1:$C$5").Value - can this return 3 columns in the listbox?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Yes.
    Set rng = Sheets("refLookups").Range($A$1:$C$5")
    
    With lbValidation
         .ColumnCount = rng.Columns.Count
         .List = rngValues
    End With
    Last edited by Norie; 02-28-2013 at 01:30 PM.

  9. #9
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Thanks for your reply. Now I have another issue: I have some of these columns formatted in % and currency formats. Range.Value is not picking up formats. How do I display formatting in the listbox?

  10. #10
    Registered User
    Join Date
    09-06-2012
    Location
    Redwood City, California
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox

    Using listbox.list does not solve the problem either! It still hangs up after the value is changed using input box.

+ 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