listbox flickering when updating from sheet

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I have two issues with a listbox.

1) I have a userform, which has a multipage on it, on the multipage there is a listbox. The listbox shows the results from sheet2, when the code is run, the sheet is populated and the results show in the listbox. As the update is rapid, the list box flickers. I have tried to add, but this is not having any luck and the flickering is still there.
VBA Code:
Application.ScreenUpdating = False
     'My code
Application.ScreenUpdating = True

Does anyone know if there is a way to stop the flickering?

2) As the list box is updating I can not scroll up or down or across, until it has finished populating. Have I missed something in the listbox propeties?

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,
would probably be more helpful to forum if you could share all the code you have that populates your listbox

Dave
 
Upvote 0
Thanks for the update. Here is the code.

VBA Code:
 With UserForm1.ListBox3
      .ColumnCount = 12
      .ColumnWidths = "160;190;70;70"
        .RowSource = "'" & Sheet2.Name & "'!$A$1:$L$" & Sheet2.Cells(Sheet2.Rows.Count, 1).End(xlUp).Row
   End With

I have had a few issues with the code as I was not 100% sure where to place it.

I tried it in the UserForm Initilize , however the Listbox is on a nested multipage and it is not the first listbox, nor on the first page, so it would not update as the data went into the sheet, once the process was finished. I had to close the for and the repoen it populate the listbox. I then placed it into the tab of the multipage so that when that page was active it would update. that did not help, similar issue. I finally placed the code into the Sheet change event for sheet 2 and that would update the listbox but flickered a lot.

Currently the its in the sheet change event
 
Upvote 0
Placing code in worksheet change event may explain the flickering

Your code should work ok in the UserForm_Intialize event

VBA Code:
Private Sub UserForm_Initialize()
    With Me.ListBox3
      .ColumnCount = 12
      .ColumnWidths = "160;190;70;70"
        .RowSource = "'" & Sheet2.Name & "'!$A$1:$L$" & Sheet2.Cells(Sheet2.Rows.Count, 1).End(xlUp).Row
   End With
End Sub

or you can qualify it to the the multipage

VBA Code:
Private Sub UserForm_Initialize()
    With Me.MultiPage2.Pages(1).ListBox3
      .ColumnCount = 12
      .ColumnWidths = "160;190;70;70"
        .RowSource = "'" & Sheet2.Name & "'!$A$1:$L$" & Sheet2.Cells(Sheet2.Rows.Count, 1).End(xlUp).Row
   End With
End Sub

You will need to change the page number as required but be mindful pages start at 0 (zero)
Also, do not make to common error of renaming this event to match your userform name

Hope helpful

Dave
 
Upvote 0
Thanks for this. However I still have the same problem. This is where the result DO NOT show in the listbox as the sheet is updated, this is why I placed the code onto the sheet2 change events as that was the only work around, however I then have flickering.
 
Upvote 0
Thanks for this. However I still have the same problem. This is where the result DO NOT show in the listbox as the sheet is updated, this is why I placed the code onto the sheet2 change events as that was the only work around, however I then have flickering.

In that case can only suggest you trying disconnecting the RowSource before you perform the Range update

VBA Code:
UserForm1.ListBox3.RowSource = ""
     'perform range update
     
    With UserForm1.ListBox3
      .ColumnCount = 12
      .ColumnWidths = "160;190;70;70"
      .RowSource = "'" & Sheet2.Name & "'!$A$1:$L$" & Sheet2.Cells(Sheet2.Rows.Count, 1).End(xlUp).Row
   End With

Or replace using RowSource with the List property of the control

VBA Code:
With UserForm1.ListBox3
      .ColumnCount = 12
      .ColumnWidths = "160;190;70;70"
      .List = Sheet2.Range("A1").CurrentRegion.Value
   End With

and see if any of these changes help

Dave
 
Upvote 0
I placed the first code in Userform Initialize and still had the same issue. I moved it to the Sheet Change Event and still had flickering.
As for the second code I get this error message
1588861302175.png
 
Upvote 0
I suspect with that error you have not copied the suggest code fully

Rich (BB code):
.List = Sheet2.Range("A1").CurrentRegion.Value

Must have Value on the end of the line of code
Also note, CurrentRegion will not work if sheet is protected

Dave
 
Upvote 0
Sheet2 is Unprotected
1588862186811.png


Q) The form opens up on Sheet1, but Data comes from Sheet2 could that be the issue.
 
Upvote 0
Sheet2 not being active should not be a problem

Are you able to place copy of your workbook in a dropbox & provide link to it?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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