Delete row if #REF! shown

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,199
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I am using this simple code =DATABASE!A202 & son on.
I have noticed that if nothing is in the cell in question then on the worksheet where there should be a value etc i see #REF !

Can we use some kind of code so that row is then deleted should #REF ! be in any cell in Column A

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Will you just have #REF! errors, or are there other error that you want to keep?
 
Last edited:
Upvote 0
This is the only one.
As items get deleted this #REF! Is then shown.
Let’s say it was looking for data in cell Z50 but then I delete Z50 this is when it appears.
If I look either side of this row I see code for Z49 in the row before and Z50 in the row after so this row which has the #REF! In is then redundant and isn’t needed or upsetting the code.
Hence why I would like it gone.
 
Upvote 0
This is the only one.
As items get deleted this #REF ! Is then shown.
Just to clarify... the question Fluff was asking is could there ever be any other errors in Column A besides #REF ! errors?

Also are you looking for a VBA solution or a manual solution?
 
Last edited:
Upvote 0
Just to clarify... the question Fluff was asking is could there ever be any other errors in Column A besides [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=REF]#REF [/URL] ! errors?

Also are you looking for a VBA solution or a manual solution?
Assuming you only will ever have #REF ! errors and no other type of errors and that a VBA solution is desired...
Code:
Sub DeleteRefErrors()
  Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End Sub
 
Upvote 0
Hi,
To apply this code is it right click on name tab and paste ?
 
Upvote 0
I see its a macro for a button.
Is there an automatic way so it monitors the sheet ?

Thanks
 
Upvote 0
Can you advise please the correct way to write this so when the worksheet is open it will run.

Code:
Private Sub Workbook_Open()With Worksheets("INV DETAILS")
  Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
  End With
End Sub
 
Upvote 0
Simply put a full stop before Columns
 
Upvote 0
Hi,
Ive put the code with another in the This workbook as shown below.
When i open the workbook i get a pop up message saying No cells found ?

Having said that is it best if i put the code back as it was and have the code run each time the worksheet is open,if so please advise.

Thanks


Code:
Private Sub Workbook_Open()With Worksheets("HONDA SHEET")
    .Activate
    Range("A13").Select
    ActiveWindow.ScrollRow = 13
    End With
    With Worksheets("INV DETAILS")
  .Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
  End With
    End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top