Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Date Input Mask

  Asked By: Joao    Date: Oct 06    Category: MS Office    Views: 796
  

I need help creating a date input mask in excel. I want to be able to
input a date as either 16122004 or 161204 and for the correct date of
16/12/04 to be displayed.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Abaigael Cohen     Answered On: Oct 06

I suggest you to take a lookbelow link that explains how to crate an excel
add-in for date  inputs via pop up calnedar
http://www.fontstuff.com/vba/vbatut07.htm
At the end of the article, you will find two download links for explained
add-in. I also put one of the mentioned links hereunder.
http://www.fontstuff.com/downloads/Excel%20Calendar%20Add-In.zip

I hope this is waht are you looking for...or....may be more...

 
Answer #2    Answered By: Abella Martin     Answered On: Oct 06
 
Answer #3    Answered By: Michelle Clark     Answered On: Oct 06

How do I change the code so that it only
accepts dates in a 6 digit format eg 161204




Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim DateStr As String

On Error GoTo EndMacro
If Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
Exit Sub
End If
If Target.Cells.Count > 1 Then
Exit Sub
End If
If Target.Value = "" Then
Exit Sub
End If

Application.EnableEvents = False
With Target
If .HasFormula = False Then
Select Case Len(.Formula)
Case 4 ' e.g., 9298 = 2-Sep-1998
DateStr = Left(.Formula, 1) & "/" & _
Mid(.Formula, 2, 1) & "/" & Right(.Formula, 2)
Case 5 ' e.g., 11298 = 12-Jan-1998 NOT 2-Nov-1998
DateStr = Left(.Formula, 1) & "/" & _
Mid(.Formula, 2, 2) & "/" & Right(.Formula, 2)
Case 6 ' e.g., 090298 = 2-Sep-1998
DateStr = Left(.Formula, 2) & "/" & _
Mid(.Formula, 3, 2) & "/" & Right(.Formula, 2)
Case 7 ' e.g., 1231998 = 23-Jan-1998 NOT 3-Dec-1998
DateStr = Left(.Formula, 1) & "/" & _
Mid(.Formula, 2, 2) & "/" & Right(.Formula, 4)
Case 8 ' e.g., 09021998 = 2-Sep-1998
DateStr = Left(.Formula, 2) & "/" & _
Mid(.Formula, 3, 2) & "/" & Right(.Formula, 4)
Case Else
Err.Raise 0
End Select
.Formula = DateValue(DateStr)
End If

End With
Application.EnableEvents = True
Exit Sub
EndMacro:
MsgBox "You did not enter a valid date."
Application.EnableEvents = True
End Sub

 
Answer #4    Answered By: Tina Simmons     Answered On: Oct 06

Please may I have some help  re my earlier message on 01/04

 
Didn't find what you were looking for? Find more on Date Input Mask Or get search suggestion and latest updates.




Tagged: