ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form Question (https://www.excelbanter.com/excel-programming/376667-form-question.html)

Barb Reinhardt

Form Question
 
I have the following code which initializes a combo box

For Each cMonth In ws.Range("Month")
With Me.cboPlanMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With
With Me.cboActMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With

Next cMonth

What I want to do is if the rangename ActMonth is not empty, populate the
value for cboActMonth with that value. I'd also like to allow the pulldown
if it's possible.

How would I do that?

Thanks

Tom Ogilvy

Form Question
 
Assuming you are uisng Ron's first suggestion:

if not isempty(Range("ActMonth")) then
With Me.cboActMonth
.Value = month(range("ActMonth"))
end with
End if

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

I have the following code which initializes a combo box

For Each cMonth In ws.Range("Month")
With Me.cboPlanMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With
With Me.cboActMonth
.AddItem cMonth.Value
.List(.ListCount - 1, 1) = cMonth.Offset(0, 1).Value
End With

Next cMonth

What I want to do is if the rangename ActMonth is not empty, populate the
value for cboActMonth with that value. I'd also like to allow the pulldown
if it's possible.

How would I do that?

Thanks



All times are GMT +1. The time now is 02:06 PM.

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