I'm trying to paste
=IF(AND(C4-C3<($I$1/1000),A4=A3),"OOOO","-----")
into a cell, which I do via
Range("I3").Select
ActiveCell.FormulaR1C1 = "=IF(AND(C4-C3<($I$1/1000),A4=A3)," & Chr(34) & "OOOO" & Chr(34) & "," & Chr(34) & "-----" & Chr(34) & ")"
Range("I3").Select
That returns Run time error '1004' Application-defined or object-defined error
I already tried double quotes and saw the & Chr(34) & workaround and tried that too. Nothing works. Furthermore, something as simple as
ActiveCell.FormulaR1C1 = "=IF("
doesn't work, but
ActiveCell.FormulaR1C1 = "=IF"
does.
Strangely, this works in the code
Range("C3").Select
ActiveCell.FormulaR1C1 = "=MID(B3,1,2)*3600+MID(B3,4,2)*60+MID(B3,7,9)"
Range("C3").Select
which I do earlier. If I paste "=MID(B3,1,2)*3600+MID(B3,4,2)*60+MID(B3,7,9)" (instead of the string I'm trying to use), into the problem code while debugging and hit Continue, it will paste that line, so its not anything that happens in between the two statements. What happens between there is just some selection and copy/pasting but I'll include it here anyway if you want to look
Range("C3").Select
ActiveCell.FormulaR1C1 = "=MID(B3,1,2)*3600+MID(B3,4,2)*60+MID(B3,7,9)"
Range("C3").Select
Selection.Copy
Range("D3").Select
Selection.End(xlDown).Select
ActiveSheet.Paste
Range("K3:Z4").Select
Application.CutCopyMode = False
Selection.Copy
Range("K1").Select
ActiveSheet.Paste
Columns("H:H").Select
Application.CutCopyMode = False
Selection.Cut
Columns("M:M").Select
ActiveSheet.Paste
Columns("I:I").Select
Selection.Cut
Columns("H:H").Select
ActiveSheet.Paste
Range("I3").Select
ActiveCell.FormulaR1C1 = "=IF(AND(C4-C3<($I$1/1000),A4=A3)," & Chr(34) & "OOOO" & Chr(34) & "," & Chr(34) & "-----" & Chr(34) & ")"
Range("I3").Select