Solved

Run time error on DirectPrecedents.Select

Posted on 2013-06-13
4
604 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 49

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 49

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

773 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