Stopping a Looping Macro

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Can someone please help this complete newbie where macros & VBA are
concerned?
I've obtained a macro from the web which does exactly what I was looking for
but I now need to tweak it a bit.
[for info: it generates random numbers in certain cells]

a) I would like it to *loop* until certain criteria are met e.g. "A1=7"
_and_ "B1 >20"

b) I would also like to be able to stop it manually [e.g. by pressing a
certain key] to prevent it going into a permanent loop.

BTW I'm using Excel 2002

Any help appreciated
TIA

Tony
 
you could use a do until loop like this

dim rg as range

Do

your macro

Set rg = (insert the cell to check here)

Loop Until rg.Value = somethin
 
hi,
To stop a macro use Ctrl+Break.
but for the loop, maybe posting your code would help.

regards
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top