excel vba - FormulaR1C1 from another WorkBook -


i've been looking @ code while , can't seem find i'm doing wrong. must 1 of obvious solutions, i'm stumped.

the line of code that's causing me trouble this:

range("m2:m5759).formular1c1 = "=if(isna(vlookup(rc[-12], " & path & "[budget " & month & ".xlsx]budget_" & month & "'!rc[-12]:r[lastr]c[-12], 1, false)), ""no"", ""yes"")"

the variable path contains location of file i'm looking at.

the name of file budget 0615.xlsx, , tab named budget_0615, date has changeable, assigned variable month.

the variable lastr contains number of rows in file.

my code trying return value "no" if value in column can't found in file budget 0615.xlsx, , return "yes" if can.

when run macro, run-time error '1004': application-defined or object-defined error.

can help? if need more info or if i'm not being clear, ask.

thanks!

you appear missing ' before path in formula, , lastr needs concatenated formula string absolute, not relative, number:

range("m2:m5759).formular1c1 = "=if(isna(vlookup(rc[-12],'" & path & "[budget " & month & ".xlsx]budget_" & month & "'!rc[-12]:r" & lastr & "c[-12], 1, false)), ""no"", ""yes"")" 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

android - Pass an Serializable object in AIDL -