![]() |
ListBox problem
I have a listbox on a userform. The listbox populates properly the first
time through. If I try to run the userform again only part of the list is there. If I close and re-open the workbook it works OK again, but not on the second pass. I have used Unload UserForm and UserForm.Hide from the OK CB on the form. How do I re-set the listbox so it will populate properly the second time? TIA, Mike |
ListBox problem
Hi Mike
It depends on how you populated the list in the first place - the nice method (setting the controlsource) is easy to update - just redefine the controlsource with the new number of rows / columns as required after each action where the user can change the underlying data. e.g. listbox1.controlsource = "A1:B10" on first run user adds 2 rows so redefine it as listbox1.controlsource = "A1:B12" If you populate the list manually (listbox1.additem) then you'll need to either identify the new / changed items and add them explicitly or clear the existing list (listbox1.clear) and add each item in turn again.... Hope this helps David "Mike Fogleman" wrote in message ... I have a listbox on a userform. The listbox populates properly the first time through. If I try to run the userform again only part of the list is there. If I close and re-open the workbook it works OK again, but not on the second pass. I have used Unload UserForm and UserForm.Hide from the OK CB on the form. How do I re-set the listbox so it will populate properly the second time? TIA, Mike |
ListBox problem
I thought the list was populated with the RowSource property? I am using the
ControlSource to store what is selected from the list, in a cell. That is set at design time. Only the Rowsource is set by code. "David Coleman" wrote in message ... Hi Mike It depends on how you populated the list in the first place - the nice method (setting the controlsource) is easy to update - just redefine the controlsource with the new number of rows / columns as required after each action where the user can change the underlying data. e.g. listbox1.controlsource = "A1:B10" on first run user adds 2 rows so redefine it as listbox1.controlsource = "A1:B12" If you populate the list manually (listbox1.additem) then you'll need to either identify the new / changed items and add them explicitly or clear the existing list (listbox1.clear) and add each item in turn again.... Hope this helps David "Mike Fogleman" wrote in message ... I have a listbox on a userform. The listbox populates properly the first time through. If I try to run the userform again only part of the list is there. If I close and re-open the workbook it works OK again, but not on the second pass. I have used Unload UserForm and UserForm.Hide from the OK CB on the form. How do I re-set the listbox so it will populate properly the second time? TIA, Mike |
ListBox problem
Hi Mike
Aaah - you spotted the deliberate mistake ;) Sorry about that - however, substitute rowsource for controlsource and my comments are still valid.... Have you tried re-defining the ROWsource after letting the user play with the data? I'm in the middle of writing a big app for a friend that has to handle this on a frequent basis and it works for me..... Regards David "Mike Fogleman" wrote in message ... I thought the list was populated with the RowSource property? I am using the ControlSource to store what is selected from the list, in a cell. That is set at design time. Only the Rowsource is set by code. "David Coleman" wrote in message ... Hi Mike It depends on how you populated the list in the first place - the nice method (setting the controlsource) is easy to update - just redefine the controlsource with the new number of rows / columns as required after each action where the user can change the underlying data. e.g. listbox1.controlsource = "A1:B10" on first run user adds 2 rows so redefine it as listbox1.controlsource = "A1:B12" If you populate the list manually (listbox1.additem) then you'll need to either identify the new / changed items and add them explicitly or clear the existing list (listbox1.clear) and add each item in turn again.... Hope this helps David "Mike Fogleman" wrote in message ... I have a listbox on a userform. The listbox populates properly the first time through. If I try to run the userform again only part of the list is there. If I close and re-open the workbook it works OK again, but not on the second pass. I have used Unload UserForm and UserForm.Hide from the OK CB on the form. How do I re-set the listbox so it will populate properly the second time? TIA, Mike |
All times are GMT +1. The time now is 08:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com