[RESOLVED] vb code to not run a macro if some cells are blank
Hi
in C9 user enters a customer number e.g. 124578
then in C10 user enters a date 16/3/2010
and from H20:H200 the user fails to enter required qty e.g. 2,5 or 100.
and runs a macro
when this happens the macro fails.
I want to stop the macro from being executed if all above 3 criterias are not fulfilled.
Can you please advise asap ... if possible.
Many thanks
Re: vb code to not run a macro if some cells are blank
assuming this is in excel
vb Code:
if isempty(range("c9")) or isempty(range("c10")) then exit sub
for each c in range("h20:h200")
if isempty(c) then exit sub
next
this does not check for valid entries
you could change the first line to
vb Code:
if not isdate(range("c10")) or not isnumeric(range("c9")) then exit sub
Re: vb code to not run a macro if some cells are blank
Hi,
Many thanks for sending the code so soon. I am very new to VB and learning by myself. can u please send me the full code including the dim variables.
thanks again
regards
Re: vb code to not run a macro if some cells are blank
Re: vb code to not run a macro if some cells are blank
Excel VBA question moved to Office Development
Re: vb code to not run a macro if some cells are blank
Thanks a lot Pete, i managed to tweak it and it worked.
Cheers