Solenya
Solenya

Reputation: 694

Type mismatch in Excel 2013

In Excel 2010 works everything fine, but in Excel 2013 the error "Type mismatch" occurs. The problem is with the following codelines (different variants I have tried).

startDate = startDateCell.Value
startDate = CDate(startDateCell.Value)
startDate = CDate(Format(startDateCell.Value, "short date"))

The content of startDateCell is f.e. a string like "12.06.2016"

startDate is a Date-variable

Upvotes: 1

Views: 120

Answers (1)

Preston
Preston

Reputation: 8197

Is it a US format date? I assume not based on the time you're posting. The problem may be that vba recognises it as a us date and interprete 13/1/2016 as 1/13/2016 (using British logic), referencing a 13th month, which gives an error.

Function Convertings() As String
  Convertings = Format(DateValue("13/1/2016"), "mm/dd/yyyy")
End Function

Upvotes: 1

Related Questions