Hi,
I just entered a very long formula in a worksheet and it works fine:
Code
=IF(IF(IF(B4="N/A",3,6)=SUM(IF(C4="N/A","",IF(VLOOKUP(C4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1))+IF(D4="N/A","",IF(VLOOKUP(D4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1))+IF(E4="N/A","",IF(VLOOKUP(E4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1))+IF(F4="N/A",0,IF(VLOOKUP(F4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1))+IF(G4="N/A",0,IF(VLOOKUP(G4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1))+IF(LEFT(H4,14)="Single Element",1,IF(H4="N/A",0,IF(VLOOKUP(H4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)="",0,1)))),"In","Out")="in",IF(B4="N/A",SUM(VLOOKUP($C4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($D4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($E4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)),SUM(VLOOKUP($C4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($D4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($E4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($F4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($G4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE)+VLOOKUP($H4,'Supplier Compoents Entry'!$A$1:$G$1000,6,FALSE))),"")
I tried recording it, but I get and Error (Compile Error: Syntax Error) when trying to play it. this is what the VBA that was recorded looks like:
Code
Range("I4").Select
ActiveCell.FormulaR1C1 = _
"=IF(IF(IF(RC[-7]=""N/A"",3,6)=SUM(IF(RC[-6]=""N/A"","""",IF(VLOOKUP(RC[-6],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1))+IF(RC[-5]=""N/A"","""",IF(VLOOKUP(RC[-5],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1))+IF(RC[-4]=""N/A"","""",IF(VLOOKUP(RC[-4],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1))+IF(RC[-3]=""N/A"",0,IF(VLOOKUP(RC[-3],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1))+IF(RC[-2]=""N/A"",0,IF(VLOOKUP(RC[-2],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1))+IF(LEFT(RC[-1],14)=""Single Element"",1,IF(RC[-1]=""N/A"",0,IF(VLOOKUP(RC[-1],'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)="""",0,1)))),""In"",""Out"")=""in"",IF(RC[-7]=""N/A"",SUM(VLOOKUP(RC3,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC4,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC5,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)),SUM(VLOOKUP(RC3,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC4,'Supplier Compoents Entry'!R1C1:R10
00C7,6,FALSE)+VLOOKUP(RC5,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC6,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC7,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE)+VLOOKUP(RC8,'Supplier Compoents Entry'!R1C1:R1000C7,6,FALSE))),"""")"
The code looks okay, but it is so long the VBA is forcing a hard return half way through and I think that this is what is causing the error, is there a way around this or do I have to split the formula into to cells?
Thanks,
Anthony