In the following vba code in excel 2010 I am getting the error message Syntax error. I think it is to do with the switch statement but can't see what is wrong. Do you know what I have done wrong?
Sub timeperiod()
Dim change As Integer, colA As Date, i As Long, val As String
For i = 2 To Rows.Count
colA = Cells(i, 1).Value
change = Day(Now) - Day(colA)
val = Cells(i, 3).Value
If change <= 0 Then
val = Switch(_
DATEDIF (colA, Now,"m") < 3 And DATEDIF (colA, Now,"m") > 0,'1 - 2 months',_
DATEDIF (colA, Now,"m") < 5 And DATEDIF (colA, Now,"m") > 2,'2 - 4 months',_
DATEDIF (colA, Now,"m") < 7 And DATEDIF (colA,Now,"m") > 4,'4 - 6 months',_
DATEDIF (colA, Now,"m") <10 And DATEDIF (colA, Now,"m") > 6, '6 - 9 months',_
DATEDIF (colA, Now,"m") > 9, '9 months+')
ElseIf change > 0 Then
val = Switch (_
DATEDIF (colA, Now,"m") = 2, '2 - 4 months',_
DATEDIF (colA, Now,"m") = 4, '4 - 6 months',_
DATEDIF (colA, Now,"m") = 6, '6 - 9 months',_
DATEDIF (colA, Now,"m") = 9, '9 months+',_
DATEDIF (colA, Now,"m") < 2 And DATEDIF (colA, Now,"m") > 0,'1 - 2 months',_
DATEDIF (colA, Now,"m") < 4 And DATEDIF (colA, Now,"m") > 2, '2 - 4 months',_
DATEDIF (colA, Now,"m") < 6 And DATEDIF (colA, Now,"m") > 4, '4 - 6 months',_
DATEDIF (colA, Now,"m") < 9 And DATEDIF (colA, Now,"m") > 6, '6 - 9 months',_
DATEDIF (colA, Now,"m") > 9, '9 months+')
End If
Next i
End Sub