Closed Thread
Results 1 to 3 of 3

Identifying error cells

Hybrid View

  1. #1
    Registered User
    Join Date
    08-05-2009
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    5

    Identifying error cells

    Hi,

    In the macro I am writing i create a data table using data from each worksheet. However, i need to delete rows which contain data from sheets that have been deleted.

    When a sheet is deleted you get a 'ref' error in the cell ie. "=#Ref!C2"

    I assumed the easiest way would be to use the sub I have for identifying empty rows, but use it to identify error cells.

    Sub DeleteRowsWithSpecifiedData()


    Sheets("Benchmarks").Unprotect Password:="scoot"
    Sheets("Benchmarks").Select


    With Range("a3:a" & ActiveSheet.UsedRange.Rows.Count)
    .FormulaR1C1 = "=IF(RC[1]="""","""",IF(RC[1]=""=#Ref!C2"",NA()))"
    .Value = .Value
    On Error Resume Next
    .SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete

    End With
    Sheets("Benchmarks").Protect Password:="scoot"
    On Error GoTo 0

    I though this would be shorter than trying to incorporate a 'sheet_delete' event macro. The problem is if there are no error cells, this deletes everything and then replaces cells A2 & A4 with 'FALSE'



    Any ideas, thanks

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Identifying error cells

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Identifying error cells

    This is (now) a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1