ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Decimal Places for NOW() in VBA versus formula (https://www.excelbanter.com/excel-programming/371045-decimal-places-now-vba-versus-formula.html)

Pete at Sappi Fine Paper

Decimal Places for NOW() in VBA versus formula
 
Okay, so I enter into cell A1 the formula =NOW(), and set the format to:

m/d/yyyy h:mm:ss.000

.... thus giving me fractions of a second to three decimal places. And those
decimal places display just fine - for example the cell currently reads:

8/21/2006 16:18:15.260

However, when I set the same cell using VBA:

Range("A" & 1) = Now()

I get this:

8/21/2006 16:18:15.000

For some reason it rounds to the nearest second. Any idea why, and how I
can fix it? Thanks!

Pete


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com