Default month

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Using XL 2000, i'm populating a combobox using:

With Month
.AddItem "January" '0
.AddItem "February" '1
.AddItem "March" '2
.AddItem "April" '3
.AddItem "May" '4
.AddItem "June" '5
.AddItem "July" '6
.AddItem "August" '7
.AddItem "September" '8
.AddItem "October" '9
.AddItem "November" '10
.AddItem "December" '11
End With

I would like the current month to default in the combobx.
any ideas appreciated.

Thanks, Paul
 
Hi Paul,

Something like this should work for you:

.Value = Format$(Date, "Mmmm")

One comment - I would pick a different name for your ComboBox, as Month is a
reserved keyword. I don't think it will cause any problems, but better safe
than sorry. I typically use "cbo" in front of a ComboBox name so I know at
first glance what type of object it is. So you could use "cboMonth" or
similar.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Good thinking Jake,
solution works fine.

Thanks, Paul

-----Original Message-----
Hi Paul,

Something like this should work for you:

.Value = Format$(Date, "Mmmm")

One comment - I would pick a different name for your ComboBox, as Month is a
reserved keyword. I don't think it will cause any problems, but better safe
than sorry. I typically use "cbo" in front of a ComboBox name so I know at
first glance what type of object it is. So you could use "cboMonth" or
similar.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Using XL 2000, i'm populating a combobox using:

With Month
.AddItem "January" '0
.AddItem "February" '1
.AddItem "March" '2
.AddItem "April" '3
.AddItem "May" '4
.AddItem "June" '5
.AddItem "July" '6
.AddItem "August" '7
.AddItem "September" '8
.AddItem "October" '9
.AddItem "November" '10
.AddItem "December" '11
End With

I would like the current month to default in the combobx.
any ideas appreciated.

Thanks, Paul

.
 
With Month
.AddItem "January" '0
.AddItem "February" '1
.AddItem "March" '2
.AddItem "April" '3
.AddItem "May" '4
.AddItem "June" '5
.AddItem "July" '6
.AddItem "August" '7
.AddItem "September" '8
.AddItem "October" '9
.AddItem "November" '10
.AddItem "December" '11
.ListIndex = Month(Date)-1
End With
 
For information:

? Format$(Date, "Mmmm")
October
? format$(date,"mMmM")
October

--
Regards,
Tom Ogilvy


Jake Marx said:
Hi Paul,

Something like this should work for you:

.Value = Format$(Date, "Mmmm")

One comment - I would pick a different name for your ComboBox, as Month is a
reserved keyword. I don't think it will cause any problems, but better safe
than sorry. I typically use "cbo" in front of a ComboBox name so I know at
first glance what type of object it is. So you could use "cboMonth" or
similar.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Using XL 2000, i'm populating a combobox using:

With Month
.AddItem "January" '0
.AddItem "February" '1
.AddItem "March" '2
.AddItem "April" '3
.AddItem "May" '4
.AddItem "June" '5
.AddItem "July" '6
.AddItem "August" '7
.AddItem "September" '8
.AddItem "October" '9
.AddItem "November" '10
.AddItem "December" '11
End With

I would like the current month to default in the combobx.
any ideas appreciated.

Thanks, Paul
 
Thanks, Tom. Actually, I like your ListIndex method better.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Tom said:
For information:

? Format$(Date, "Mmmm")
October
? format$(date,"mMmM")
October


Jake Marx said:
Hi Paul,

Something like this should work for you:

.Value = Format$(Date, "Mmmm")

One comment - I would pick a different name for your ComboBox, as
Month is a reserved keyword. I don't think it will cause any
problems, but better safe than sorry. I typically use "cbo" in
front of a ComboBox name so I know at first glance what type of
object it is. So you could use "cboMonth" or similar.

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Using XL 2000, i'm populating a combobox using:

With Month
.AddItem "January" '0
.AddItem "February" '1
.AddItem "March" '2
.AddItem "April" '3
.AddItem "May" '4
.AddItem "June" '5
.AddItem "July" '6
.AddItem "August" '7
.AddItem "September" '8
.AddItem "October" '9
.AddItem "November" '10
.AddItem "December" '11
End With

I would like the current month to default in the combobx.
any ideas appreciated.

Thanks, Paul
 
Back
Top