View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default excel vba date format prob.

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

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"jo11 " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/