Put the DoEvents outside the if statement
just before the 'loop'
Maybe your program loop is not getting to the DoEvents