Best way of working with a slow VBA function

I have a custom VBA function that performs a number of functions, including a Google address lookup on the net that makes the function slow. To avoid running it continuously I have installed it in a Worksheet Selection_Change event so that it runs only after I have moved to a new row. However I am looking for a better way of managing it, especially when I paste a whole range of new cells in my spreadsheet, as well as still running when I make a change to nominated columns. Any suggestions?
LVL 1
Rob4077Asked:
Who is Participating?

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

x
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.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
it depends on how often/ quickly that info need to be reflected on your worksheet.

if you want a "real time" effect, then you probably can use Worksheet Selection_Change event, but to not slow down the whole performance, you can detect if a row is changed, and only look up with Google address if there's any changes.

OR you probably can have a Button to bulk update the list of cells that lookup with Google address. a Userform with a proper progress bar can be designed in case you want to make it more user friendly.
0

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
Rob4077Author Commented:
Thanks Ryan. Your comments made me realise that a Worksheet Change event could be used to trap when a change is made to a key column in a range and use that to trigger a lookup. If there's no change to a key column then there's no need to run a complex lookup but if there's a change to a key column then I just loop through the range and refresh the lookups. I need to test a little more but it seems to be working Ok.

Thanks for leading me to the solution
0
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
Microsoft Excel

From novice to tech pro — start learning today.