View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chris Gorham Chris Gorham is offline
external usenet poster
 
Posts: 32
Default Stopping Code from Running whilst in Loop...

Hi,

I'm performing a series of operations on cells within the used range of a
s/sheet. A summary of the code is as follows:

Dim c as range

on error goto errhandler
Application.EnableCancelKey = xlErrorHandler

For Each c In ActiveSheet.UsedRange

.....series of operations on each cell....

next c

exit sub

errhandler:

end sub

I'd like to give the user the option of breaking out of the loop using the
escape key. However the code stubbornly refuses to do this in practice...
I've tried using "doevents" without any luck - although I'm not sure that
I'm applying it correctly.

Suggestions....

Rgds....Chris