Results 1 to 7 of 7

Thread: Click on userform transfers to listbox below

  1. #1

    Click on userform transfers to listbox below



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi and thanks in advance,

    I am using Excel 2003

    I have a userform with a listbox. When the user clicks a button on that form it opens another form with colour choices via a whole bunch of image controls. A problem occurs when I click on one of the image controls that sits directly over the listbox on the userform below. What happens is, I click the colour I want and the Colour form closes as expected but the mouse click then selects a row in the userform listbox below.

    Thanks

    Deutz

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,294
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Dont' have an example to test, but I'd probably either:
    -Code to select what I want to selecton on UserForm1 during UserForm'2s UserForm_Terminate event
    -Code to select what I want in UserForm1's UserForm_Activate event (which should fire when it is reactivated.
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3

    Example spreadsheet attached

    Hi Ken,

    Thanks for your suggestions but Activate/Terminate events did not work. I have attached a scaled down version of the code and forms that are causing the problem with the listbox selections.

    Thanks
    Attached Files Attached Files

  4. #4
    This is a workaround you can use until it can be determined what the issue is. This code will position the Userform2 so it is not on top of the listbox after it opens. As long as userform2 does not touch the listbox everything works fine.

    The code runs on the form initialize event.
    You may have to adjust the width setting on you r machine . it is currently set at +220
    Code:
    Private Sub UserForm_Initialize()
    Me.StartUpPosition = 0
    Me.Top = (Application.Height - Me.Height) / 2
    Me.Left = (Application.Width - Me.Width + 220)
    End Sub

  5. #5
    Thanks for your suggestions.

    Someone else suggested I hide the second form rather than unload it and use buttons on the main form rather than images and this fixed the problem.

  6. #6
    Just change your event sub to mouseUp instead of mouseDown.

  7. #7
    Thanks nevadaDave

    That also works.

Posting Permissions

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