Importing data disables equations in VBA

I import worksheets This_ws and Ref_ws, each from a separate workbook, into a master workbook,

I create the following equation in This_ws in the master workbook.


The code that creates the equation in This_ws is:
Range(Cells(2, 15), Cells(LastRow, 15)).Formula = "=INDEX(Ref_ws!H:H,MATCH(This_ws1!B:B,Ref_ws!B:B,0))"

The problem is that, if Ref_ws exists when I open the workbook and I try and run the macro to import and populate the equation in This_ws, the equation yields an #N/A (value not found) error.

I have to always import the Ref_ws (even if it already exists in the master workbook) and THEN run the macro to import and populate This_ws for the equation to work.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
Your formula should be...

Range(Cells(2, 15), Cells(LastRow, 15)).Formula = "=INDEX(Ref_ws!H:H,MATCH(This_ws1!B2,Ref_ws!B:B,0))"

Open in new window

Also when you say importing?? From where you are importing this??


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EdLBAuthor Commented:
Bam. That worked. Thanks! That has been bugging me for months.
Saurabh Singh TeotiaCommented:
You are welcome.. Always happy to help.. :-)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.