excel vba date format prob.

  • Thread starter Thread starter jo11
  • Start date Start date
J

jo11

I have a problem with formating the dates in my macro, when the macro is
done i need to go into the cell and press <enter>! but as I need this
action to take place in the macro, how do I do this??????

I have tried for a month and nothing happens!!

Y.S.
Jo
 
Hi

Make sure your macro knows it's really a date before pasting by using a date variable. I
also suggest to use Dateserial for setting this, (y, m, d) , then you are independent of
the computer's regional settings and formats.

Sub Macro1()
Dim D As Date
D = DateSerial(2004, 1, 30)
Range("A1").Value = D
'and if you want to:
'Range("A1").NumberFormat = "dddd mmm.d yyyy"
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

Back
Top