New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

VBA switching month/dates

Macros, VBA, Excel Automation, etc.

Re: VBA switching month/dates

Postby Don » Wed Jan 11, 2012 4:20 pm

Glad you got it worked-out! Thanks for sharing the final solution!
  • 0

Don
Moderator
 
Posts: 733
Joined: Dec 4, 2011
Reputation: 2
Excel Version: 2010

Re: VBA switching month/dates

Postby Sisyphus » Wed Jan 11, 2012 9:51 pm

Hi,
Yes. That is likely to prove stable because you leave the management of the Date entirely to Excel. Your program doesn't interfere, and the only way the user can cause a muck-up is by formatting the target cell in some way you don't like. If you want to guard against that you can set the format of the target cell.

In slow motion:
The datepicker delivers a Date. It is a date number.
The worksheet receives the Date as a number.
It interprets this Date by local Excel rules. Day, month and year are all correct.
The receiving cell is formatted by Excel as a Date automatically. Local Excel rules are applied.
The precise date format chosen is determined by the Sheet, Workbook or System defaults, whichever is applicable. Local Excel decides.
Hence, if you haven't set the required cell format anywhere the result may be unexpected and subject to occasional change. On the other hand, if you set the cell format programmatically it can't interfere with the date value because that is determined by the Datepicker and brought to the cell without modification.
  • 0

Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010

Previous

Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 237 guests