Delete #N/A

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
136
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?
 

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
136
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,182,145
Messages
5,933,889
Members
436,916
Latest member
LonN90

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