Copy rows which have a result after applying the LOOKUPV(filter them from #N/A)

vbanew98

New Member
Joined
Aug 31, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I am working with an excel which has about 500000 rows. I have one sheet called "B" where is all the info and I only need the rows where the column Y contains text, not de #N/A from the LOOKUP. I have to copy the rows with info, to another sheet called "A". I used this code for the same process

On Error Resume Next Columns("Y").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete On Error GoTo 0

But in this case, there are many rows so it takes 5 minutes(not worthy)

I only have 3000 rows with non NA, so I thought it will be easier to filter them and copy to "A" the entire row(the column A from the row in "B" it's not necessary, and the destination sheet "A" the column A has to be empty). I don't know how to do it, i'm new in this language, thank you
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
So weird, no reason that "SpecialCells method" works so slow!
Iit took me 0.48 seconds with almost 500,000 VLOOKUP formula in column Y with "N/A"
VBA Code:
Sub del()
Dim t
t = Timer
On Error Resume Next
Columns("Y").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
MsgBox Timer - t
End Sub

Could you share the whole code?
 
Upvote 0
Thanks bebo021999 for spending your time on it. It's a laptop provided by the company, I don't know a lot about computers but I supposed it is power limited. Regards
 
Upvote 0
So weird, no reason that "SpecialCells method" works so slow!
Iit took me 0.48 seconds with almost 500,000 VLOOKUP formula in column Y with "N/A"
VBA Code:
Sub del()
Dim t
t = Timer
On Error Resume Next
Columns("Y").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
MsgBox Timer - t
End Sub

Could you share the whole code?
The whole code is:

Sub AutoDelete()
Worksheets("B").Activate
On Error Resume Next
Columns("Y").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
End Sub
 
Upvote 0
I could not find any wrong process in that full code
Normally, using specialcells method is best way to delete rows at once (in bulk) !
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,579
Members
452,653
Latest member
craigje92

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