Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Application defined error

Hi,

the attached piece of code is failing on the line

  .Range("J2").Formula = "=IF(ISERR(I3-F2),"""",I3-F2))"

Its saying

Application defined or Object defined error

This is in the VB editor, can anyone see what is wrong with the forumula?

Thanks
Seamus
Sub FillFormula()

Dim r As Long

With Sheets("Pay Rec Data")
    r = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("D2").Formula = "=IF(B2=""entered"",""Yes"",IF(B2="""","""",""No""))"
    .Range("E2").Formula = "=IF(D2=""Yes"",MID(C2,4,10),"""")"
    .Range("F2").Formula = "=IF(D2=""Yes"",RIGHT(C2,8),"""")"
    .Range("G2").Formula = "=IF(B2=""left at"",""Yes"",IF(B2="""","""",""No""))"
    .Range("H2").Formula = "=IF(D2=""No"",C2,"""")"
    .Range("I2").Formula = "=IF(D2=""No"",C2,"""")"
    .Range("J2").Formula = "=IF(ISERR(I3-F2),"""",I3-F2))"
    .Range("K2").Formula = "=J2"
    .Range("L2").Formula = "=IF(A2=""travseam"",""Seamus Travers"","""")"
    
    .Range("D2:L2").Copy .Range("D2:L" & r)
End With

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seamus2626

ASKER

Thanks Thomas!