excel input date format

G

Guest

Hi
Thanks in advance for any help.
I have this small macro
Dim myDateP1
myDateP1 = InputBox("Enter START date for report PERIOD in dd-mm-yy
format")
If myDateP1 <> "" Then
If IsDate(myDateP1) Then
' MsgBox "Continue the macro"
' Selection.NumberFormat = "dd/mm/yyyy"
' ActiveCell.Offset(0, 2).Range("A1").Select
Selection.FormulaR1C1 = myDateP1
Range("n4").Select
Selection.FormulaR1C1 = "=(r[-3]c)"
' Selection.NumberFormat = "dd/mm/yyyy"
Else
MsgBox "You did not enter a date"
End If
End If

seeking the user to input a date, in the format dd/mm/yy This part work.
However when the date is placed into the cell the format becomes mm/dd/yy.

I know I'm doing something wrong and it might be the new year blues.

Is anyone able to guide me. as you can see by the rem I've tryied formating
the cells.

Thanks
Noel
 
B

Bob Phillips

Noel,

Change

Selection.FormulaR1C1 = myDateP1

to

Selection.FormulaR1C1 = CDate(myDateP1)

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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