Delete Row based on cell value

esmecat

New Member
Joined
May 5, 2010
Messages
19
I had some help with this recently and its been working great until now!

I have just tried it again and have hit a snag - using the code below it is successfully deleting all but 'Anglia' which is being replaced with #N/A but the rows remain.

Dim Addr As String
Application.ScreenUpdating = False
With Sheets("Data Tab")
Addr = "A2:A" & Cells(Rows.Count, "A").End(xlUp).Row
Range(Addr) = Evaluate(Replace("IF(@=""Anglia"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Kent"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""LNW North"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""LNW South"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""No Route Defined"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Scotland"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Sussex"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Wales"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Wessex"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Western Thames Valley"",""#N/A"",@)", "@", Addr))
Range(Addr) = Evaluate(Replace("IF(@=""Western West"",""#N/A"",@)", "@", Addr))
On Error GoTo NoDeletes
Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
End With
NoDeletes:
Application.ScreenUpdating = True[/QUOTE]

Guidance would be appreciated.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In the "Anglia" line, try :
• Deleting ""#N/A"" and retyping it
• Replacing ""#N/A"" with ""#REF!""
 
Upvote 0

Forum statistics

Threads
1,216,235
Messages
6,129,650
Members
449,524
Latest member
RAmraj R

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