#1
|
|||
|
|||
Date Format for days 01-12 are americanized
Hi All
I have created a spreadsheet that uses a userform to enter data. The first field of the data is the date which I have set up as dd/mm/yyyy. Once the form is completed the USER presses the Add Record button and the VBA code places the data at the end of the current table. I have the column set up in the spreadsheet as short date format dd/mm/yyyy. The issue is for any day 1st to the 12th the date goes into the cell as mm/dd/yyyy however the format of the cell is still dd/mm/yyyy. eg 8th Sept 2015 goes in as 9/08/2015 and becomes 9th Aug 2015. Any date after the 12th works fine. I have checked though my VBA code by adding msgbox's to see the value of the variable and even upto the line prior to the value being saved into the cell the Variable is correct. I am adding the value to the cell with ".Cells(lRow, 1).Value = Me.pDate.Value" (see below) Are there any suggestions as to how I can fix this issue. Quote:
|
#2
|
|||
|
|||
see if either of these work
Code:
.Cells(lRow, 1).Value = Format(Me.pDate.Value, "Short Date") .Cells(lRow, 1).Value = Me.pDate.Text |
#3
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thanks
I tried these but no luck |
#5
|
|||
|
|||
It looks like this could be the issue but is there a way to fix this, it seems anything days 1-12 come across as serial numbers but all other dates come across as a short date.
|
#6
|
|||
|
|||
jcrennan
Can you post a sample file with user form which behaves this way ? Also, what is the setting of Short Date in your regional settings ? |
#7
|
|||
|
|||
Quote:
If you goto the Totals Worksheet and use Add Entry button this will bring up the form. When you click the Add record button on the form the details from the user form get added to the Programs Worksheet. To test select an entry that is in the 1st twelve days on the month and then also do an entry for one that is in the later part of the month. The PC regional settings is English(Australia) Short Date d/MM/yyyy |
#8
|
||||
|
||||
Try changing:
Me.pDate.Value = Format(Date, "dd/mm/yyyy") to: Me.pDate.Value = Format(Date, "dd mmm yyyy")
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Thanks Very much that seems to work fine and has solved my issue
|
#10
|
|||
|
|||
Glad you got the situation rectified.
For what it's worth, I think the root of the problem is actually in the CommandButton1_Click procedure of the ufPrograms userform. Commenting out the second formatting line allowed everything to display dd/mm/yyyy as desired and on my machine and I have Regional Settings Short Date set as M/d/yyyy. Code:
Private Sub CommandButton1_Click() Me.pDate.Value = Format(CalendarForm.GetDate, "dd/mm/yyyy") 'Me.pDate.Value = Format(Me.pDate.Value, Text) End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to count even exact date 90 days | redza | Excel | 1 | 09-17-2013 03:36 AM |
Date Field to add 10 Days to Current Date | Erbwon | Word | 6 | 11-12-2012 06:17 PM |
Set calendar alarm x days before end date | el_ja | Outlook | 2 | 01-19-2012 10:09 AM |
30+ days Variable Day Date Calculations via Fields | ztag | Word | 2 | 01-06-2012 11:12 AM |
Creating an Auto-Calc'd Date? Today+7 Days? | SoCalTelephone | Word | 0 | 10-06-2010 10:27 AM |