Just a variation of Tom's suggestion.
If data_rng is a named range (Insert|name|define), then drop the range() from
the formular1c1:
ActiveCell.FormulaR1C1 = _
"=if(iserror(VLOOKUP(RC1,[book2.xls]Sheet1!data_rng,2,FALSE))," _
& """"",VLOOKUP(RC1,[book2.xls]Sheet1!data_rng,2,FALSE))"
(You were missing a closing parentheses at the end, too.)
===
If data_rng is a variable that represents a range on sheet1 of the
abretesemamo.xls workbook, then maybe you could do it this way:
dim data_rng as range
with workbooks("abretesesamo.xls").worksheets("sheet1")
set data_rng = .range("A1:B999")
'or even .range("somename")
set data_rng = .range("somename")
'or just for overkill...
'the variable has the same spelling as the named range!
'it might make it easier to keep track of things
set data_rng = .range("data_rng")
end with
ActiveCell.FormulaR1C1 = _
"=if(iserror(VLOOKUP(RC1," & _
data_rng.Address(external:=True, ReferenceStyle:=xlR1C1) & ",2,FALSE))," _
& """"",VLOOKUP(RC1," & _
data_rng.Address(external:=True, ReferenceStyle:=xlR1C1) & ",2,FALSE))"
What is wrong with this line.It gives me a syntax error
ActiveCell.FormulaR1C1 = _
"=if(iserror(VLOOKUP(RC1,[abretesesamo.xls]Sheet1!range(data_rng),2,FALSE)),
_
"""",VLOOKUP(RC1,[abretesesamo.xls]Sheet1!range(data_rng),2,FALSE)"
Thanks for your help