use doevents before starting the code, this will enable you to receive events from the command button inbetween.

Ritesh