[英]Change date format in list view EXCEL VBA
I have a listview but when macro is launched, it changes date format from "[h]:mm:ss" to General. 我有一个listview,但是启动宏时,它将日期格式从“ [h]:mm:ss”更改为“常规”。
My code says this 我的代码说
itmX.SubItems(4) = Range("F" & i).Value
itmX.SubItems(5) = Range("G" & i).Value
itmX.SubItems(6) = Range("H" & i).Value
itmX.SubItems(7) = Range("I" & i).Value
Is there any way to fix it? 有什么办法可以解决? In order to get format "[h]:mm:ss"?
为了获得格式“ [h]:mm:ss”? Thank you very much
非常感谢你
try after you've replaced the .value with .text
, it should look like this: 在将
.value with .text
替换为.value with .text
之后,请尝试如下所示:
timX.SubItems(4) = Range("F" & i).Text
times and dates are just masks for a number in excel today's date or a time value are just numbers with a format mask like below 时间和日期只是excel中今天日期的数字的掩码,或者时间值只是具有以下格式掩码的数字
26/01/16 = 42395
1:02:03 = 0,0430902777777778
With the value
you're setting your subitems to the underlying value of the cell 使用该
value
您可以将子项设置为单元格的基础值
numberformat
property
numberformat
属性
ThisWorkbook.Worksheets("Name of your worksheet").Range("A1").NumberFormat = "[H]:mm:ss"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.