ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   resetting a listbox after a macro (https://www.excelbanter.com/excel-programming/415071-resetting-listbox-after-macro.html)

rivers

resetting a listbox after a macro
 
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

JLGWhiz

resetting a listbox after a macro
 
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.



"Rivers" wrote:

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


rivers

resetting a listbox after a macro
 
its on form its a row setting linked to a sheet and the code is too big to post

"JLGWhiz" wrote:

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.



"Rivers" wrote:

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


Rick Rothstein \(MVP - VB\)[_2486_]

resetting a listbox after a macro
 
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


"Rivers" wrote in message
...
its on form its a row setting linked to a sheet and the code is too big to
post

"JLGWhiz" wrote:

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.



"Rivers" wrote:

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



JLGWhiz

resetting a listbox after a macro
 
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.

"Rivers" wrote:

its on form its a row setting linked to a sheet and the code is too big to post

"JLGWhiz" wrote:

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.



"Rivers" wrote:

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


rivers

resetting a listbox after a 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

"JLGWhiz" wrote:

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.

"Rivers" wrote:

its on form its a row setting linked to a sheet and the code is too big to post

"JLGWhiz" wrote:

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.



"Rivers" wrote:

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


Dick Kusleika[_4_]

resetting a listbox after a macro
 
On Mon, 4 Aug 2008 11:59:01 -0700, Rivers
wrote:

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/arch...stboxcombobox/

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).
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com


All times are GMT +1. The time now is 07:35 PM.

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