I'm trying to parse a String in VB to Date in an Excel macro like this:
Sub report_macro()
Dim nRow As Long
Dim sDueDate As String
Dim dueDate As Date
For nRow = 5 To 65536
If Not Range("A" & nRow).Value = "" Then
sDueDate = Range("G" & nRow).Value
dueDate = Date.ParseExact(sDueDate, "yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo)
If Range("H" & nRow).Value = 57600 Then
Range("A" & nRow & ":I" & nRow).Select
Selection.Font.Bold = True
With Selection.Interior
.Color = 13551615
End With
End If
Else
Exit For
End If
Next nRow
End Sub
I'm getting Sytnax error at the line:
dueDate = Date.ParseExact(sDueDate, "yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo)
What am I doing wrong?