View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Felix Dalldorf[_2_] Felix Dalldorf[_2_] is offline
external usenet poster
 
Posts: 2
Default Error Handling - EditGo ToSpecial

This is a different way to get to the same problem. When the macro encounters
the line:
set rng = Selection.RowDifferences(Activecell)

the 1004 error condition is raised. The problem is there is no way I have
found around the 1004 error as it is not one you can trap using "On Error"
handling according to the documentation.

What I have found in practice is that the "On Error" condition does work
sometimes. In my current sheet, I have 4 sets of columns I am trying to loop
through to compare. The first set has row differences so the range function
evaluates fine.
The second set has no row differences, but the "On Error Go To" function
works to divert the processing for the null condition.
The third set has no row differences but the macro dies with error 1004.

Reseting and clearing the error conditions makes no difference.


"Jim Thomlinson" wrote:

You are best off to handle this with a range object something like this

dim rng as range

on error resume next
set rng = Selection.RowDifferences(Activecell)
on error goto 0

if not rng is nothing then rng.select

--
HTH...

Jim Thomlinson


"Felix Dalldorf" wrote:

I am having trouble trapping certain kinds of errors in Visual Basic macros.
Specifically I can't seem to trap errors related to the "EditGo ToSpecial"
variety.

For example, if two columns are selected, and I try to locate rowdifferences
between the columns using:

Selection.RowDifferences(Activecell).Select

will work fine if there are row diffrences. If there are no differences, I
get error 1004, which I can't trap using "On Error" handling.

I have the same problem if the Macro tries to look for Blank cells.

Does anyone have a solution for how to trap and handle these errors?