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
Bookmarks