PDA

View Full Version : Add formula to cell



tommy1234
03-28-2010, 04:29 AM
Hello
I wrote a long formula in excel and i want to save time by insert it with code.
The formula is :
"=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0))=TRUE,0,VLOOKUP($A73,Shee t1!$A$1:$M$173,10,0))"

What should i write in order to insrt it by code ?

Help is needed

Thanks

mdmackillop
03-28-2010, 04:36 AM
You can insert a formula as a range name and call it as in =Test
or

ActiveCell.Formula = "=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0))=TRUE,0,VLOOKUP($A73,Shee t1!$A$1:$M$173,10,0))"

Bob Phillips
03-28-2010, 07:49 AM
Unnecessary test for TRUE



ActiveCell.Formula = "=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0)),0,VLOOKUP($A73,Sheet1!$A $1:$M$173,10,0))"