View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Using Now with microseconds Excel 2003

Option Explicit
Sub testme()
With ActiveSheet.Range("A1")
.NumberFormat = "mm/dd/yyyy hh:mm:ss.000"
.Formula = "=now()"
.Value2 = .Value2
End With
End Sub



ian wrote:

I want to use a macro to put in date time in a cell with microseconds.

I've tried Range("a1").Value = Format(Now, " dd-mm-yyyy hh.mm.ss.
000")

which doesn't work for the milliseconds.

If I enter =now() in a cell manually and use custom format dd/mm/yyyy
hh:mm:ss:000 it works.

Any suggestions please?

I want to create a unique date time reference in each row and thought
I'd use a time date function.

Thanks.


--

Dave Peterson