ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "ComboBox1.ListIndex = 0" Doesn't seem to always work. (https://www.excelbanter.com/excel-programming/408540-combobox1-listindex-%3D-0-doesnt-seem-always-work.html)

JudgeMental

"ComboBox1.ListIndex = 0" Doesn't seem to always work.
 
Hi,

I have "ComboBox1" on a UserForm. In the Sub Form Initialize procedure, I
have "ComboBox1.ListIndex = 0" hoping to set the ComboBox to Index 0 every
time the Form is loaded. The problem is that maybe 50% of the time it loads
up with the last selection instead. Am I doing something wrong?

Thank you for your help!

JLGWhiz

"ComboBox1.ListIndex = 0" Doesn't seem to always work.
 
If you are hiding your UserForm instead of unloading it, then the initialize
event won't fire when you show it again and your ComboBox will show the last
selected value. Since you didn't post all of your code, I can't tell you
much more.

"JudgeMental" wrote:

Hi,

I have "ComboBox1" on a UserForm. In the Sub Form Initialize procedure, I
have "ComboBox1.ListIndex = 0" hoping to set the ComboBox to Index 0 every
time the Form is loaded. The problem is that maybe 50% of the time it loads
up with the last selection instead. Am I doing something wrong?

Thank you for your help!


Jon Peltier

"ComboBox1.ListIndex = 0" Doesn't seem to always work.
 
If indeed the form was hidden, you could put the code into UserForm_Activate
to reset it when it is redisplayed.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"JLGWhiz" wrote in message
...
If you are hiding your UserForm instead of unloading it, then the
initialize
event won't fire when you show it again and your ComboBox will show the
last
selected value. Since you didn't post all of your code, I can't tell you
much more.

"JudgeMental" wrote:

Hi,

I have "ComboBox1" on a UserForm. In the Sub Form Initialize procedure, I
have "ComboBox1.ListIndex = 0" hoping to set the ComboBox to Index 0
every
time the Form is loaded. The problem is that maybe 50% of the time it
loads
up with the last selection instead. Am I doing something wrong?

Thank you for your help!





All times are GMT +1. The time now is 03:01 AM.

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