Solved

Run time error on DirectPrecedents.Select

Posted on 2013-06-13
4
592 Views
Last Modified: 2013-06-13
Hello

I am struggling with my error handling in VBA (please refer below for an extract of code).

       Worksheet.Cells.Select

       On Error GoTo NoPrecedentCells
       Selection.DirectPrecedents.Select

NoPrecedentCells:

End Sub

Regardless of the "On Error" command, a run-time error 1004 (No cells were found) arises.

Can you assist in anyway.

Thanks and regards
Aidan
0
Comment
Question by:a_norton
  • 2
  • 2
4 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39243777
Hi,

Have you verified in the VBE Options/ General  your Error Trapping Status

Break on All errors OR Break in Class Module OR Break on Unhandled Errors ( the right one)

Regards
0
 

Author Comment

by:a_norton
ID: 39243812
Hello,

My Error Trapping Status appears to be set to Break on Unhandled Errors...

Is this correct?  On this setting the problem does however persist :(
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39244288
Pls try

Sub DoIt()
ActiveSheet.Cells.Select
On Error Resume Next
PredCount = Selection.Precedents.Count
On Error GoTo 0
If PredCount = Empty Then
    GoTo NoPrecedentCells
Else
    Selection.DirectPrecedents.Select
End If
NoPrecedentCells:
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:a_norton
ID: 39244376
Thanks you so much!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now