What could be the reason, that I get the the Run-Time Error '13' Type Mismatch with this line of VBA Code:
可能是因为我得到了这行VBA代码的运行时错误'13'类型不匹配:
.Cells(1, 1) = CDate(Format(Now, "dd.mm.yy hh:mm"))
The problem is, that a colleague doesn't get this error. We have both a "German" office.
问题是,一位同事没有得到这个错误。我们都有一个“德国”办公室。
1 个解决方案
#1
8
I'm not sure why you need the format, since its just being turned straight back into a Date before you fill the cell.
我不确定你为什么需要这种格式,因为它只是在你填充单元格之前直接转回日期。
You should really either have:
你应该真的要么:
.Cells(1, 1) = Format(Now,"dd.mm.yy hh:mm")
or even better
甚至更好
.Cells(1, 1) = Now
then format the column as follows:
然后格式化列如下:
Columns("A:A").NumberFormat = "dd.mm.yy hh:mm"
Note: Its possible that having the mm in the format string could not help, although having just tried it out it seems to work ok.
注意:格式字符串中的mm可能无法帮助,虽然刚试了一下它似乎工作正常。
#1
8
I'm not sure why you need the format, since its just being turned straight back into a Date before you fill the cell.
我不确定你为什么需要这种格式,因为它只是在你填充单元格之前直接转回日期。
You should really either have:
你应该真的要么:
.Cells(1, 1) = Format(Now,"dd.mm.yy hh:mm")
or even better
甚至更好
.Cells(1, 1) = Now
then format the column as follows:
然后格式化列如下:
Columns("A:A").NumberFormat = "dd.mm.yy hh:mm"
Note: Its possible that having the mm in the format string could not help, although having just tried it out it seems to work ok.
注意:格式字符串中的mm可能无法帮助,虽然刚试了一下它似乎工作正常。