Entering dates QUICKLY

D

DOMINIC JOSLIN

How do I enter dates without using the / key. Eg 071004 instead of 07/10/04
(this could of course be any date). I have seen applications set up this
way, but I have not been able to find a reference to how it is done. Any
ideas?
 
B

Ben McBen

Hi Dominic


there is probably an eay way to do this - but I dont know
it. However two alternatice approaches.

1. Use an adjacent cell to parse the input and generate a
valid date. eg

=DATEVALUE(LEFT(F16,2) &"/" & MID(F16,3,2) &"/" & RIGHT
(F16,4))

where F16 contains a DDMMYYYY "date" input.

2. Use the worksheet change event: You need to stop it
going into an endless loop. this is done by turning off
events while processing the change:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next

Application.EnableEvents = False

If Target.Column = "3" And Target.Value2 <> "" Then

Target.Value = DateValue(Left(Target.Value2, 2) & "/"
& Mid(Target.Value2, 3, 2) & "/" & Right(Target.Value2, 4))

End If

Application.EnableEvents = True


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top