Display milliseconds in Excel

后端 未结 4 1429
深忆病人
深忆病人 2020-12-01 05:18

I am trying to display milliseconds in an Excel macro. I have a column of integers which are timestamps in milliseconds (e.g. 28095200 is 7:48:15.200 am), and I want to mak

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 05:32

    Right click on Cell B1 and choose Format Cells. In Custom, put the following in the text box labeled Type:

    [h]:mm:ss.000 
    

    To set this in code, you can do something like:

    Range("A1").NumberFormat = "[h]:mm:ss.000"
    

    That should give you what you're looking for.

    NOTE: Specially formatted fields often require that the column width be wide enough for the entire contents of the formatted text. Otherwise, the text will display as ######.

提交回复
热议问题