if statement with vlookup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

if range(vlookup(a1,[data.xls]inventory!$K$2:$L$1000,2,0).value = "accessory"
then
application.run "macro1"
else
application.run "macro2"

i know my error is in in the equation just cant figure it out
thanks in advance
 
Without testing, try (the 1st two lines here are ONE line)

if application.vlookup(range("a1"),workbook("data.xls"). _
sheets("inventory").range($K$2:$L$1000),2,0) = "accessory" then
macro1
else
macro2
end if

Many usually define a name and then just
if vlookup([a1],definednamerange,etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top