I am getting an error EXCEL VBA APPLICATION-DEFINED OR OBJECT-DEFINED ERROR on the last line of the loop. I have looked it up but with nothing applying that I have read.
For i = 1 To PatCnt - 1
Range("E" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Patient:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Patient:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("F" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Primary:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Primary:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("G" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Secondary:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Secondary:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("H" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Patient Total:""" & "," & "PatientL" & i & ",43,FALSE))," & """""" & ",VLOOKUP(" & """Patient Total:""" & "," & "PatientL" & i & ",4,FALSE))"
Range("I" & i + 1).Formula = _
"=IF(OR(AND(CELLS(" & """E""" & i + 1 & ") = """""" & "",CELLS(" & """F""" & i + 1 & ")=" & """""" & ",CELLS(" & """G""" & i + 1 & ")=" & """""" & "),MAX(CELLS(" & """E""" & i + 1 & "):CELLS(" & """G""" & i + 1 & "))>NOW()-365)," & "OK" & "," & "Dated" & ")"""
Next i
the vlookups work fine it is the if(or(and line that is messing up.
Any help would be greatly appreciated.
Thanks
David
For i = 1 To PatCnt - 1
Range("E" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Patient:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Patient:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("F" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Primary:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Primary:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("G" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Secondary:""" & "," & "PatientL" & i & ",3,FALSE))," & """""" & ",VLOOKUP(" & """Secondary:""" & "," & "PatientL" & i & ",3,FALSE))"
Range("H" & i + 1).Formula = _
"=IF(ISNA(VLOOKUP(" & """Patient Total:""" & "," & "PatientL" & i & ",43,FALSE))," & """""" & ",VLOOKUP(" & """Patient Total:""" & "," & "PatientL" & i & ",4,FALSE))"
Range("I" & i + 1).Formula = _
"=IF(OR(AND(CELLS(" & """E""" & i + 1 & ") = """""" & "",CELLS(" & """F""" & i + 1 & ")=" & """""" & ",CELLS(" & """G""" & i + 1 & ")=" & """""" & "),MAX(CELLS(" & """E""" & i + 1 & "):CELLS(" & """G""" & i + 1 & "))>NOW()-365)," & "OK" & "," & "Dated" & ")"""
Next i
the vlookups work fine it is the if(or(and line that is messing up.
Any help would be greatly appreciated.
Thanks
David