Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2015, 08:36 PM
jcrennan jcrennan is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Novice
Date Format for days 01-12 are americanized
 
Join Date: Sep 2015
Posts: 5
jcrennan is on a distinguished road
Default 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:
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
MsgBox (Me.pDate.Value)
With ws
.Cells(lRow, 1).Value = Me.pDate.Value
.Cells(lRow, 2).Value = Me.pType.Value
.Cells(lRow, 3).Value = Me.pParticipants.Value
.Cells(lRow, 4).Value = Me.pEarly.Value
.Cells(lRow, 5).Value = Me.pJunior.Value
.Cells(lRow, 6).Value = Me.pYouth.Value
.Cells(lRow, 7).Value = Me.pAdult.Value
.Cells(lRow, 8).Value = Me.pSenior.Value
.Cells(lRow, 9).Value = Me.pComments.Value
.Cells(lRow, 10).Value = Month(Me.pDate.Value)
End With
Reply With Quote
  #2  
Old 09-06-2015, 09:32 PM
NoSparks NoSparks is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

see if either of these work
Code:
.Cells(lRow, 1).Value = Format(Me.pDate.Value, "Short Date")

.Cells(lRow, 1).Value = Me.pDate.Text
Reply With Quote
  #3  
Old 09-07-2015, 04:42 AM
macropod's Avatar
macropod macropod is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by jcrennan View Post
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. ...
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 think you'll find the serial value of the date being output by the userform is as per the dates displayed in the worksheet...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 09-07-2015, 06:49 PM
jcrennan jcrennan is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Novice
Date Format for days 01-12 are americanized
 
Join Date: Sep 2015
Posts: 5
jcrennan is on a distinguished road
Default

Thanks

Quote:
Originally Posted by NoSparks View Post
see if either of these work
Code:
.Cells(lRow, 1).Value = Format(Me.pDate.Value, "Short Date")
 
.Cells(lRow, 1).Value = Me.pDate.Text
I tried these but no luck
Reply With Quote
  #5  
Old 09-07-2015, 07:05 PM
jcrennan jcrennan is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Novice
Date Format for days 01-12 are americanized
 
Join Date: Sep 2015
Posts: 5
jcrennan is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I think you'll find the serial value of the date being output by the userform is as per the dates displayed in the worksheet...
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.
Reply With Quote
  #6  
Old 09-07-2015, 07:11 PM
NoSparks NoSparks is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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 ?
Reply With Quote
  #7  
Old 09-07-2015, 08:40 PM
jcrennan jcrennan is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Novice
Date Format for days 01-12 are americanized
 
Join Date: Sep 2015
Posts: 5
jcrennan is on a distinguished road
Default

Quote:
Originally Posted by NoSparks View Post
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 ?
I have attached an empty copy

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
Attached Files
File Type: xlsm MASTER File - Programs Daily Stats 2015-2016.xlsm (136.4 KB, 11 views)
Reply With Quote
  #8  
Old 09-07-2015, 09:11 PM
macropod's Avatar
macropod macropod is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #9  
Old 09-07-2015, 09:37 PM
jcrennan jcrennan is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Novice
Date Format for days 01-12 are americanized
 
Join Date: Sep 2015
Posts: 5
jcrennan is on a distinguished road
Thumbs up

Quote:
Originally Posted by macropod View Post
Try changing:
Me.pDate.Value = Format(Date, "dd/mm/yyyy")
to:
Me.pDate.Value = Format(Date, "dd mmm yyyy")
Thanks Very much that seems to work fine and has solved my issue
Reply With Quote
  #10  
Old 09-08-2015, 01:33 PM
NoSparks NoSparks is offline Date Format for days 01-12 are americanized Windows 7 64bit Date Format for days 01-12 are americanized Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Format for days 01-12 are americanized How to count even exact date 90 days redza Excel 1 09-17-2013 03:36 AM
Date Format for days 01-12 are americanized 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft