running a macro only if criteria are met

T

The Grinch

hello all,

I have a macro that runs fine, the problem is it relies on user input
and will run even if the data received is invalid. I can calculat
simple checks to confirm if the user has inputted valid data, an
simply set a test cell to either "YES" or "NO".

Is there any way I can amend the macro such that if the cell reads "NO
the macro stops and gives the user a relevant message, and if the cel
reads "YES", the macro runs through as normal.

any help/comments will be appreciated.

CHEER
 
F

Frank Kabel

Hi
within you macro try something like the following:
sub foo()
if activesheet.range("A1").value="No" then
msgbox "macro is stopped"
exit sub
end if
'you code
end sub
 
T

The Grinch

thats cracked it thanks very much!!

PS- i cant do it in the IF statement because i have to run the macro a
its doing other stuff aswell
 
Top