I'm trying to add code to enter a formula to several columns and copy to the end of the row. The VBA works for one of the columns (AB) but I get a syntax error for column AC. The formula works in excel if I enter it manually. Any idea why this is and how it can be fixed?
Sub AddHeaders()
Dim ws As Worksheet
Set ws = ActiveSheet
Dim used As Range
Set used = ws.UsedRange
Dim lastRow As Integer
lastRow = used.Row + used.Rows.Count - 1
ws.Range("AB6:AB" & lastRow).Formula = "=IF(ISNUMBER(J6),J6,IF(LEN(J6)=9,DATE(RIGHT(J6,4),LEFT(J6,1),MID(J6,3,2)),IF(LEN(J6)=10,DATE(RIGHT(J6,4),LEFT(J6,2),MID(J6,4,2)))))"
ws.Range("AC6:AC" & lastRow).Formula = "=IF(AND(WORKDAY(TODAY(),20)-AB6<=28,WORKDAY(TODAY(),20)-AB6>=0),"yes","no")"
End Sub
Thanks