Delete row if #REF! shown

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
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
 
Is the code you posted in post#16 the only code in the open event, or have you removed other code to "simplify" things?
The reason I ask is the as I stated the On Error resume next should prevent the error message, unless VBA is already handling another error
 
Upvote 0

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
Just making sure that im on the same page as you.

Alt & F11
Double click ThisWorkBook


This is all the code now shown on the right.
Code:
Option Explicit


Private Sub Workbook_BeforeClose(Cancel As Boolean)


    With Sheets("HONDA SHEET").Range("C1:F17").Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent5
        .TintAndShade = 0.599993896298105
        .PatternTintAndShade = 0
    End With
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Sheets("HONDA SHEET").Range("A2,A17").ClearContents
Application.EnableEvents = True
End Sub
Private Sub Workbook_Open()
   Worksheets("HONDA SHEET").Activate
   Range("A13").Select
   ActiveWindow.ScrollRow = 13
   With Worksheets("INV DETAILS")
      On Error Resume Next
      .Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
      On Error GoTo 0
   End With
End Sub


If i right click on the INV DETAILS tab & click on View Code its empty.

Thanks
 
Last edited by a moderator:
Upvote 0
Don't understand this.
Try closing down Xl completely, then open the workbook, do you still get the error message?
 
Upvote 0
In that case I have no idea what is happening.
 
Upvote 0
Evening,
Fluff,Ive just had a though.

Its more of a workaround so that message isnt shown when i open the worksheet.

How about we put #REF! in a cell when the worksheet closes each time.
That way each time it opens we shouldnt see that message as it will have a
#REF! to delete the row

The row would need to be far away from my work like row 20000 etc ?

What do you think.
If possible how do we do it.

Thanks
 
Upvote 0
Try
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
   Application.EnableEvents = False
   Sheets("HONDA SHEET").Range("A2,A17").ClearContents
   Sheets("Inv Details").Range("A" & Rows.Count).End(xlUp).Offset(4).Value = "#N/A"
   Application.EnableEvents = True

End Sub
 
Upvote 0
I get the same message and this is shown in yellow when i debug
.Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete

I also see the #NA Being put in 4th row after my last row with data in.

If this will not work without that error then maybe have a macro to delete the #REF ! upon that worksheet when activated,will this then delete them once i open that sheet ?

Just saves me clicking a button every time.
 
Upvote 0
What happens if you comment out the lines in red, do you still get the error?
Code:
Private Sub Workbook_Open()
  [COLOR=#ff0000] Worksheets("HONDA SHEET").Activate
   Range("A13").Select
   ActiveWindow.ScrollRow = 13[/COLOR]
   With Worksheets("INV DETAILS")
      On Error Resume Next
      .Columns("A").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
      On Error GoTo 0
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,847
Messages
6,121,911
Members
449,054
Latest member
luca142

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