CellExists versus On Error

A

Andy

My application copies cells between shapes, some of these cells exists
on both the source and destination shapes other exists only on one or
other.

I am currently checking if the cell exists on the destination shape
and the source shape before doing the copy of the cell. Is it better to
do these checks or to ignore the checks and just use 'On Error Resume
Next' to ignore any errors.

Any suggestions,

thanks Andy
 
A

Al Edlund

since OnError doesn't do any native logging, when invoked with a resume next
you never know if your operation completed correctly until much later.
al
 
J

JuneTheSecond

It would depend on what, you might think, important.
But I always select your way of CellExist.
 
P

pschatz

There is a performance hit for the method that uses the
OnErrorResumeNext. If you are doing this often, you will find a
sizeable performance advantage to checking for the cell's existence
instead.
 
C

Chris [Visio MVP]

Just letting the error happen seems very fast in VBA or VB, but if you move
to VB.NET, the exception handling can be quite slow.

Errors should be for exceptions. In this case, it is often the case that a
cell is not there, and is therefore NOT an exception.

Doing the check will probably be better in the long run.
 
A

Andy

Thanks for everyones advice, as I was already doing the checks I will
leave it that way. Seems the right thing to do.
 

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

Top