Delete row if #REF! shown

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,428
Office Version
  1. 365
Platform
  1. Windows
Will you just have #REF! errors, or are there other error that you want to keep?
 
Last edited:

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows
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.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,967
Office Version
  1. 2016
Platform
  1. Windows
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:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,967
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

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
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows
Hi,
To apply this code is it right click on name tab and paste ?
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows

ADVERTISEMENT

I see its a macro for a button.
Is there an automatic way so it monitors the sheet ?

Thanks
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,428
Office Version
  1. 365
Platform
  1. Windows
Simply put a full stop before Columns
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,923
Office Version
  1. 2007
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,316
Messages
5,635,521
Members
416,862
Latest member
MGDlite

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
Top