View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
filo666 filo666 is offline
external usenet poster
 
Posts: 265
Default on error resume next

Imagine this case:
A B C D
1 "HOLA"
2 1
3 6
4 25

WITH MY CODE:
sub gtt()
for a=1 to 10
cell(a,1)=cell(a,1)+cell(a,2)
cell(c,5)="Hola" ' if the line below is error DON'T go here
msgbox "Error en lo establecido " & cell(a,1) , vbokonly, "Error"
next 'if error goto this next
end sub

the part cell(a,1)=cell(a,1)+cell(a,2) is going to fail because "HOLA"+1=Error
but if I put something to tell VB to jump to the next value of the a and
continues all the code, all the code is executated well.
There are 2 way to acomplish this:
1. if isnumeric(cells(a,1))=true then
blalbalblablalbalba
else
a=a+1
end if
2. THE ONE I'M LOOKING FOR

HHS
TIA



"Bob Phillips" wrote:

so what do you want to happen then?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"filo666" wrote in message
...
but, what happen if the error ocurres in other part of the macro different

of
the loop?????

"tony h" wrote:


sub gtt()
on error goto AnError:
for a=1 to 10
cell(a,1)=cell(a,1)+cell(a,2)
cell(c,5)="Hola" ' if the line below is error DON'T go here
msgbox "Error en lo establecido " & cell(a,1) , vbokonly, "Error"
AnError:
next 'if error goto this next
end sub


on the basis that this is a limited loop it isn't too dangerous


--
tony h
------------------------------------------------------------------------
tony h's Profile:

http://www.excelforum.com/member.php...o&userid=21074
View this thread:

http://www.excelforum.com/showthread...hreadid=505378