User Form Macro - Date Format is Changing from UK to US format on spreadsheet

Lesgrimes

New Member
Joined
Oct 12, 2011
Messages
5
Hi All,

after receiving a cracking answer to an issue I raised yesterday on the Forum, I now seem to have an issue with around Date Formats

For my user form I have 3 different text boxes for Date entry, so I have set up code for each one to format the Date into UK format

Private Sub TextBoxNewDeliveryDate_AfterUpdate()If IsDate(Me.TextBoxNewDeliveryDate) Then
Me.TextBoxNewDeliveryDate = Format(Me.TextBoxNewDeliveryDate, "dd/mm/yy")
End If
End Sub

This seems to allow me to put the date into the user form correctly.

However, when I then click on the Save button and the code copies the values to the spreadsheet the dates have changed format to US!!! It appears to be quite selective as well, as days which could be seen as months 1 to 12 are changing and all dates past the 13th do not change.

'Copy Input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Non Conformance")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBoxDateEntry.Value
.Cells(lRow, 2).Value = Me.ComboBoxShip.Value
.Cells(lRow, 3).Value = Me.ComboBoxCategory.Value
.Cells(lRow, 4).Value = Me.ComboBoxType.Value
.Cells(lRow, 5).Value = Me.TextBoxOrigDelDate.Value
.Cells(lRow, 6).Value = Me.TextBoxOrigDestination.Value
.Cells(lRow, 7).Value = Me.TextBoxPONumber.Value
.Cells(lRow, 8).Value = Me.TextBoxSKUNumber.Value
.Cells(lRow, 10).Value = Me.TextBoxNewDeliveryDate.Value

I've tried formatting the columns on the spreadsheet but this does nothing as I presume the code is overwriting it?

Do I need to add some code to the copy VBA or somewhere else?

Thanks in advance
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try
Code:
.Cells(lRow, 1).Value = CLng(Me.TextBoxDateEntry.Value)
 
Upvote 0
Thank you Mr Fluff, excuse my ignorance but I tried replacing the line
.Cells(lRow, 1).Value = Me.TextBoxDateEntry.Value
with your suggested code and it brought up an error message.
I presume with my lack of coding skills I put the new code in the wrong place?
 
Upvote 0
Apologies it should have been
Code:
[COLOR=#ff0000]CDate[/COLOR](Me.TextBox1.Value)
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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