Delete #N/A

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a sheet wherein I do a Vlookup. For the values that are not found, it generates the #N/A error.

I am trying to delete those rows which have the #N/A error, but it is not deleting


1663349041448.png


This is my code. I call the Del_Rows in my main code by using Call Del_Rows

<code>
Sub Del_Rows()
Dim wbexcel As Workbook
Dim ws As Worksheet
Dim LR As Long, i As Long

Set wbexcel = ThisWorkbook
Set ws = wbexcel.Sheets("TSS Fails")

LR = ws.Range("AU2:AU" & Rows.Count).End(xlUp).Row
For i = LR To Step - 1
If Cells("AU2" & i).Text = "#N/A" Then Rows(i).EntireRow.Delete
Next i

End Sub

</code>

What am I doing wrong?
 
I'm glad it worked for you. I hope you will also (when you have time) take the time to read over the comments/correct to your code. It's fundamental concepts in VBA that you need to understand to prevent similar things from happening again in the future. (And that post was technically answering the question of this thread.)
Absolutely! Will do
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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