resetting a listbox after a macro

  • Thread starter Thread starter Rivers
  • Start date Start date
R

Rivers

hi all

is it possible to refresh a listbox in a form after a macro has run?

the list box is poplated by options on a worksheets the user selects an
option then the listboxes options change. what i require is the selected line
to disappear again to allow the user to select a new optioin at the moment
the line selected stays blue after the macro has updated its values

thanks
rivers
 
Is the ListBox on a Sheet or a UserForm? Is it initially loaded by RowSource
or by List or by AddItem. If on a Sheet, is it from the Forms toolbar or
from the Control Toolbox. Also, if it has associated code, you should post
that as well.
 
Just a guess (without being able to see if your code is interfering in any
way)... try setting the ListIndex property to -1 (minus one)... doing that
should leave no item selected.

Rick
 
In addition to Rick's suggestion, unloading the UserForm will also reset all
the controls on it. But of course that would take some code modification if
you are now hiding the form (which is what it sounds like) instead of
unloading it. But without knowing exactly how you are initializing the
UserForm and how it is being handled to cause the ListBox to retain the
selected value, I can't offer much more.
 
sorry guys

i think we have our wires crossed a little

the list box has a row source linked to the spreadsheet. when the macros
done it clears the rows of data that the list box looks at thus turning the
list box blank.

however the option i selected before running the macro say line 3 of the
list box is still coloured blue its value is empty but still highlighted im
looking for a way to turn the list box from being highlighted after i have
run the macro
 
sorry guys

i think we have our wires crossed a little

the list box has a row source linked to the spreadsheet. when the macros
done it clears the rows of data that the list box looks at thus turning the
list box blank.

however the option i selected before running the macro say line 3 of the
list box is still coloured blue its value is empty but still highlighted im
looking for a way to turn the list box from being highlighted after i have
run the macro

I never use rowsource.
http://www.dailydoseofexcel.com/archives/2004/05/07/populating-one-column-listboxcombobox/

However, I think you need to code

Me.ListBox1.Rowsource = ""

when you clear the range. And reset it to the range address when you
repopulate the range (or sometime just before you show the form).
 
Back
Top