User Form Update From Listbox -- Not Refreshing

stefanchik

New Member
Joined
Apr 27, 2011
Messages
1
HI

I've trawled the boards and tried different things for hours .. to no avail

Maybe its something simple that I'm missing ? .. but I'm just not seeing it even though I've tried endless combinations

I have a User_Form that contains 2 List_Boxes .. these act as a progress bar .. showing the user in list_box 1 how many items populated into list_box 2 have so far been actioned

The Userform is called by .show on a VBA routine
Userform properties are set to 'Enabled' = true .... 'Modal' = false
Listbox properties are Visible=true, ... Enabled = true , ... Locked = false

The userform initialization code is:
ListBox2.ColumnCount = 1
ListBox2.RowSource = "H1"
ListBox2.ControlSource = "H1"
ListBox2.SetFocus
ListBox1.ColumnCount = 1
ListBox1.RowSource = "I1"
ListBox1.ControlSource = "I1"
ListBox1.SetFocus
Exit Sub

Issue
-- when the form is FIRST called .. the listboxes are blank ... as nothing has yet been written to H1 and I1 by the main routine program
-- when the main routine FIRST populates these H1 & I1 cells ( via code as shown below ) , the listboxes update with the two values
-- ( H1 is a static value that will never change once its been set in )
--- I've tried a million things, but nothing will ever get the User Form list-box to re-update from its original entered value of " 1 " in cell I1, even though the value of cell I1 has been physically changed in the excel cell by the main routine in its " while-wend " loop of the Nr of items so far actioned ... " UNLESS " that is, that after ' Do Events ', that I unload the userform .. and then immediately load it back up .. but then the box is flicking constantly on-off the screen which is not great to the users eye

The main sequence code in the while-wend loop that populates the cells is as below
... any help on how to make list box 1 update when I change the value of cell I1 is vastly appreciated :)

Matching_Row_Nr.Show
Range("H1").Select
ActiveCell.Value = "" + NrMatchingRows + ""
Range("I1").Select
ActiveCell.Value = "" + ThisMatchingRowNr + ""
Matching_Row_Nr.Repaint
DoEvents
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,303
Office Version
  1. 2010
Platform
  1. Windows
hi and welcome to MrExcel. i am a bit confused about why you would choose a listbox, but then keep changing the contents. list boxes are not intended for that purpose
 

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Range("H1").Select
ActiveCell.Value = "" + NrMatchingRows + ""
Range("I1").Select
ActiveCell.Value = "" + ThisMatchingRowNr + ""
This lines are outside the userform placed in a module.
Maybe you can put them in the userform somewhere by a change_event.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,112
Messages
5,640,174
Members
417,130
Latest member
Darion2021

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
Top