Using Now with microseconds Excel 2003

I

ian

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.
 
G

Guest

Dim d As Double
d = Evaluate("Now()")
Range("A1") = d

format A1 in the worksheet or in VBA to match your reqs.
 
D

Dave Peterson

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

Dana DeLouis

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

Another option...

Sub Demo()
[A1] = [TEXT(NOW(),"dd-mm-yyyy hh.mm.ss.000")]
End Sub
 
I

ian

Thanks

I used Dave's method. The answer is rounded to the nearest 10 milli-
seconds.

Yes Tim, I made a mistake in the question, milli-seconds is fine,

Ian
 

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