Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run time error on DirectPrecedents.Select

Posted on 2013-06-13
4
Medium Priority
?
624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

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 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

704 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