ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ScreenUpdating and listboxes (https://www.excelbanter.com/excel-programming/436013-screenupdating-listboxes.html)

Merlynsdad

ScreenUpdating and listboxes
 
I'm populating listboxes and want to reduce screen flicker. If I populate
them between the screenupdating=false and screenupdating=true commands, the
items in the listboxes aren't displayed. If I don't use the screenupdating
commands all of the objects on the page flicker each time a line is added to
the listbox. Is there a way to see these items wihle still eliminating the
flicker?

B Lynn B

ScreenUpdating and listboxes
 
It will be easier to help if you post the code you're using to populate them.

"Merlynsdad" wrote:

I'm populating listboxes and want to reduce screen flicker. If I populate
them between the screenupdating=false and screenupdating=true commands, the
items in the listboxes aren't displayed. If I don't use the screenupdating
commands all of the objects on the page flicker each time a line is added to
the listbox. Is there a way to see these items wihle still eliminating the
flicker?


Merlynsdad

ScreenUpdating and listboxes
 
Here's the code:

Application.ScreenUpdating = False

Set wsq = ActiveSheet

Me.Activate
lstEmpFrom.Clear
lstEmpTo.Clear

'Make the EmpMonDates collection

On Error Resume Next
For Each cell In wsq.Range("$b$17:$b$100")
EmpMonDates.Add cell.Value, CStr(cell.Value)
Next cell

'Sort the EmpMonDates collection

For i = 1 To EmpMonDates.Count - 1
For j = i + 1 To EmpMonDates.Count
If EmpMonDates(i) EmpMonDates(j) Then
Swap1 = EmpMonDates(i)
Swap2 = EmpMonDates(j)
EmpMonDates.Add Swap1, befo=j
EmpMonDates.Add Swap2, befo=i
EmpMonDates.Remove i + j
EmpMonDates.Remove j + i
End If
Next j
Next i

On Error GoTo 0

'Add the dates to the list boxes

For Each Item In EmpMonDates
ActiveSheet.lstEmpFrom.AddItem Item
ActiveSheet.lstEmpTo.AddItem Item
Next Item
Application.ScreenUpdating = True

"B Lynn B" wrote:

It will be easier to help if you post the code you're using to populate them.

"Merlynsdad" wrote:

I'm populating listboxes and want to reduce screen flicker. If I populate
them between the screenupdating=false and screenupdating=true commands, the
items in the listboxes aren't displayed. If I don't use the screenupdating
commands all of the objects on the page flicker each time a line is added to
the listbox. Is there a way to see these items wihle still eliminating the
flicker?


Merlynsdad

ScreenUpdating and listboxes
 
Here's the code:

Application.ScreenUpdating = False
Set wsq = ActiveSheet

Me.Activate
lstEmpFrom.Clear
lstEmpTo.Clear

'Make the EmpMonDates collection

On Error Resume Next
For Each cell In wsq.Range("$b$17:$b$100")
EmpMonDates.Add cell.Value, CStr(cell.Value)
Next cell

'Sort the EmpMonDates collection

For i = 1 To EmpMonDates.Count - 1
For j = i + 1 To EmpMonDates.Count
If EmpMonDates(i) EmpMonDates(j) Then
Swap1 = EmpMonDates(i)
Swap2 = EmpMonDates(j)
EmpMonDates.Add Swap1, befo=j
EmpMonDates.Add Swap2, befo=i
EmpMonDates.Remove i + j
EmpMonDates.Remove j + i
End If
Next j
Next i

On Error GoTo 0

'Add the dates to the list boxes

For Each Item In EmpMonDates
ActiveSheet.lstEmpFrom.AddItem Item
ActiveSheet.lstEmpTo.AddItem Item
Next Item
Application.ScreenUpdating = True

"B Lynn B" wrote:

It will be easier to help if you post the code you're using to populate them.

"Merlynsdad" wrote:

I'm populating listboxes and want to reduce screen flicker. If I populate
them between the screenupdating=false and screenupdating=true commands, the
items in the listboxes aren't displayed. If I don't use the screenupdating
commands all of the objects on the page flicker each time a line is added to
the listbox. Is there a way to see these items wihle still eliminating the
flicker?



All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com