Some suggestions...
Set the number format for the rowsource cells to text.
Make sure the cells display exactly what you want to display in the combobox.
Comment out the line... UserForm5.Controls("ComboBox1").Value =
Format(UserForm5.Controls("ComboBox1").Value, "mmm-yy")
Use a Select Case format instead of multiple If's.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
"anon"
wrote in message
Hi,
I've created a userform which is a calendar. The month displayed is
controlled by a combobox on the userform, so whichever month selected
in the combobox controls the dates displayed in the textboxes below.
I have a problem however. The months available to select in the
combobox are;
May-08
Jun-08
Jul-08
Aug-08
Sep-08
Oct-08
Nov-08
Dec-08
Jan-09
Feb-09
Mar-09
Apr-09
May-09
Jun-09
Jul-09
These are in a sheet on my workbook and the combobox rowsource is set
to sheet4!af1:sheet4!af15 (where these are located). The code that
runs when a user makes a selection;
Private Sub ComboBox1_Change()
UserForm5.Controls("ComboBox1").Value =
Format(UserForm5.Controls("ComboBox1").Value, "mmm-yy")
If ComboBox1.Value = "May-08" Then Call may08
If ComboBox1.Value = "Jun-08" Then Call june08
If ComboBox1.Value = "Jul-08" Then Call july08
If ComboBox1.Value = "Aug-08" Then Call august08
If ComboBox1.Value = "Sep-08" Then Call september08
If ComboBox1.Value = "Oct-08" Then Call october08
If ComboBox1.Value = "Nov-08" Then Call november08
If ComboBox1.Value = "Dec-08" Then Call december08
If ComboBox1.Value = "Jan-09" Then Call january09
If ComboBox1.Value = "Feb-09" Then Call february09
If ComboBox1.Value = "Mar-09" Then Call march09
If ComboBox1.Value = "Apr-09" Then Call april09
If ComboBox1.Value = "May-09" Then Call may09
If ComboBox1.Value = "Jun-09" Then Call june09
If ComboBox1.Value = "Jul-09" Then Call july09
End Sub
When i load the form and select the combobox I can see all of the
options, however if I select a month in 2009 the combobox defaults to
the same month in 2008. So if I select Jul-09 from the combobox the
combobox shows Jul-08 and therefore the dates shown in my textboxes
are July 2008 dates.
I have checked all of the sub's named in the code exist but cannot
figure why this is happening. Does anyone have any ideas?