Forum Discussion
Anonymous
Jun 12, 2019Setting one fixed format of date in Excel Cells
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 ab...
- Jun 13, 2019
Deleted Here's en example using this code.
Anonymous
Jun 18, 2019PeterBartholomew1 Thank you, will have to try and let you know.
JKPieterse
Jun 18, 2019Silver Contributor
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- AnonymousJun 18, 2019
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.
- JKPieterseJun 18, 2019Silver ContributorClear the LinkedCell property of the date picker.
- AnonymousJun 18, 2019