SOLVED

Setting one fixed format of date in Excel Cells

Deleted
Not applicable

Hello there,

 

I'm trying to set only one format of date acceptable into excel cells. In no instance a user shall feed in a different format of a date or even if he/she does, Excel sheet must be able to auto correct and set it back to the acceptable format.

 

I've tried 'Format Cells' and Data Validation which were of no help.

 

The acceptable format I'm trying to freeze is DD Month YYYY (Eg. 12 June 2019)

 

Please enlighten me with more options if available or to use data validation in excel to achieve.

 

Thank You

18 Replies
This is far from simple to make absolutely 100% secure, as it is easy to break a conditional formatting rule by a simple copy and paste.
One way to make pasting harder is by merging two cells next to each other before setting up the Validation on the merged cells, unlocking the merged cell (and setting a date format) and then protecting the worksheet.
Thanks, firstly, is t.hat even achievable in Excel? I mean a standard date format set for a column and users entering data whatsoever ways will be autocorrected to the fixed format.
Also, I can use the 'Excel Date Picker Add on' then let the users pick up a date, however, this would require the users to have the add on installed on their systems. So trying to figure out if by any way I can keep the users from entering data in a wrong or different format.
More or less, if it is entered in a form Excel can turn into a date it will do so, but you risk Excel getting it wrong of people type dates in the wrong day/month order. There is no fool-proof way to avoid that other than by using VBA I think. Even then there are always ways around it. Database applications are much better equipped for a task like this.

@Jan Karel Pieterse 

 

So it looks like I'll have to depend on VBA for this. Any idea what the code would probably look like?

best response
Solution

@Deleted Here's en example using this code.

Thank you so much, I think I got what I have been looking for.

I have used the following URL to set up the date picker in Excel, which has been successful. However, I couldn't get the required format which is mm-dd-yyyy. I have used the same VBA code as in the URL. Could someone please help?

 

https://github.com/Amallard/excelTricks/blob/master/DatePickerToCells.md

 

Thanks,

Karthick.S

@Deleted 

Conditional formatting appears to work.

Number formatting set as a conditional format to any positive number greater than 30000 (say) will override any input default or user setting.

 

That is, until someone overwrites the conditional format of course.

Best to include your file (scrubbed of any sensitive information!) so we can see what you tried.

@Jan Karel Pieterse 

 

Sure, here we go.

@Peter Bartholomew  Thank you, will have to try and let you know.

@Deleted Change the code to match the code below and format your cells with the proper date format.

Option Explicit

Private Sub DTPicker1_Change()
    ActiveCell.Value = CDate(DTPicker1.Value)
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    With Sheet1.DTPicker1
        .Height = 20
        .Width = 20
        If Not Intersect(Target, Range("A:A")) Is Nothing Then
            .Visible = True
            .Top = Target.Top
            .Left = Target.Offset(0, 1).Left
            .Value = Target.Value
        Else
            .Visible = False
        End If
    End With

End Sub

@Jan Karel Pieterse 

 

Thank you so much, it works!!. However, one cell alone changes back to a different format by itself. Not sure why. Have attached the sheet.

Clear the LinkedCell property of the date picker.

@Jan Karel Pieterse 

 

Thanks a ton, it worked. 

By the way, will this work when I send the sheet to users that may not have date picker control installed in their systems?

No it will not. Hence my proposition to use that other one.
1 best response

Accepted Solutions
best response
Solution

@Deleted Here's en example using this code.

View solution in original post