Userform Bugginess

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
810
Office Version
  1. 365
Platform
  1. Windows
Hi chaps

I have a userform which contains a couple listboxes within a frame, with buttons below and a JPG above, nothing major. However, every time I load it, the elements are misplaced - the listboxes overlap each other, etc. If I click and drag the Userform window around, it resolves itself.

But my listboxes have selection change code in them. If I select one item on one listbox, the other updates dynamically. When this happens, everything jumbles itself up again, and I have to jiggle the window to sort it out.

I've added this code as per Senor GPT, which hasn't really stopped the Userform window being comically large (which seems to be aonther bug entirely) - To solve THAT bug, I need to go into the actual Userform in the VBA window and press one of the handles to resize the userform, then it snaps back to its proper size. What a mess!!

VBA Code:
Dim originalWidth As Double
    originalWidth = Me.Width
    Me.Width = originalWidth + 10
    Me.Width = originalWidth
    Me.Repaint

I'm on office 365.


Anyone got any tricks up their sleeve? TBH This file has two Userforms and they both do this crap, but the one I'm talking about here is way worse for it.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Your profile still says 2010...

Which build are you on? There was one that had a load of userform problems, but that was a while ago.
Need to change that..

Version 2404 (Build 17531.20062)


I added a bit of code on Userform Initialize & ListBox Change events to wiggle the Userform left and then right one pixel, which seems to have solved one problem, in addition to manually setting the size of the Userform on initialize.
 
Upvote 0
Bump. Just came to make this thread again and then realised it's already here. Can anyone help? Thanks.
 
Upvote 0
I've never seen this before, so I think you might have to provide a link to the workbook so we can see if it's something wrong with the workbook itself, or something local to you.
 
Upvote 0
Hm, I doubt I can as it has sensitive work information in it that's hard to purge.

I think part of it might be the interplay between opening the XL workbook and then changing the screen I'm using for work. For instance, using it on my laptop & then plugging into my dock which has a higher res display. That seems to play havoc with many parts of Excel and I guess the 1992 VBA Userform code is no different.
 
Upvote 0
Hi RockandGrohl. Screen resolution and personalization settings will affect the userform and it's controls. See the code I posted at this link to see if it helps. Dave
edit: there's an API that needs conversion to 64bit
VBA Code:
#If VBA7 And Win64 Then
Public Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
#Else
Public Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
#End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top