Excel VBA make a script asynchronous

You can't do too much about this unfortunately since VBA runs in a single thread.

You can however introduce a degree of responsiveness by putting

VBA.DoEvents()

in various places in your code, ideally in the tight loops. In your case, put them just after the lines containing For. This pauses the VBA and flushes the event queue which will have the effect of making Excel responsive.

(Toggling the screen updating is a bad idea since you might leave things in a bad state if the function terminates unexpectedly. I'd remove the lines that do that if I were you.)


Excel can calculate "asynchronously". Call sPing as a function.

I'm not sure why your range is A1:N50. I assume one of the columns is the IP address, which I will assume as A. So your formula in column M will look like =sPing(A1).

As for the color coding, you can use conditional formatting.