Private sub running twice

BoboBarlow

New Member
Joined
Oct 22, 2013
Messages
2
Hi all,

I have a drop down box selecting from a list of dates (Oct-13 - Dec-14) that I need to display as "mmm-yy" to the end user so have written the following code to format when a date is selected:

Code:
Private Sub SDatePicker_Change()
    SDatePicker.Value = Format(SDatePicker.Value, "mmm-yy")
End Sub

For some reason the code seems to run through itself twice and I can't figure out why. The result of this is an incorrect date being displayed (strangely when I select 'Jan-14' for example, the result is 'Jan-13'.

Any thoughts?

Thanks in advance

John

EDIT*

Perhaps I should point out that the default formatting of the date values seems to be in number format e.g. 41976.
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try

Code:
Private Sub SDatePicker_Change()
Application.EnableEvents = False
    SDatePicker.Value = Format(SDatePicker.Value, "mmm-yy")
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi Peter, thanks for replying. Unfortunately it hasn't worked.

The weird thing is, it only seems to be happening on two drop down boxes I have relating to 'start' and 'end' dates, I have another that selects names from a list but this doesn't happen.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top