What could be the reason, that I get the the Run-Time Error '13' Type Mismatch with this line of VBA Code:
.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.
Scan for malware or for viruses. Try to start your antivirus and check the system; this may be the reason for the runtime error 13 type mismatch. Just before starting the scan, make sure that your antivirus is updated and functions well. The result of the procedure depends on it.
However, this error can still occur and has the following causes and solutions: Cause: The variable or property isn't of the correct type. For example, a variable that requires an integer value can't accept a string value unless the whole string can be recognized as an integer.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With