ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting default value for combo box (https://www.excelbanter.com/excel-programming/376845-setting-default-value-combo-box.html)

Barb Reinhardt

Setting default value for combo box
 
I'm populating the values for a combo box using the following:

With Me.cboPlanMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With

I have saved a value of the planned month as PlanMonth and would like for
the combo box to default to that value when it's opened. What do I need to
do to get this to work?

Thanks

Bob Phillips

Setting default value for combo box
 
With Me.cboPlanMonth
.AddItem cMonth.Value
If cMonth.Value = PlanMonth Then
.ListIndex = .ListCount -1
End If
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Barb Reinhardt" wrote in message
...
I'm populating the values for a combo box using the following:

With Me.cboPlanMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With

I have saved a value of the planned month as PlanMonth and would like for
the combo box to default to that value when it's opened. What do I need

to
do to get this to work?

Thanks





All times are GMT +1. The time now is 11:15 AM.

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