delete row with specific content

Galceran

Board Regular
Joined
Nov 8, 2008
Messages
177
Excel 2003. This is a database of 892 entries. We already have a script which finishes by removing most of the columns ready for saving as a CSV file for an Address Book which is then emailed to the mailing dept. One member does not want the monthly updates. Fortunately his firstname is Andre the e is shown as acute.

At the start of formatting for the csv part we need to do a find for Andre and delete the row. This is the vba we are struggling with. As new members join Andre is likely to be moved down a row each time. The Alpha-Numeric sort takes place before the CSV formatting.

Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
The quickest method I've found for doing a similar exercise is to turn on the Autofilter, filter as appropriate and then delete the visible rows.
 
Upvote 0
Ah yes but, we want this in VBA, and it looks like it would always delete row 549, the next time Andre would be on a different row.
Thanks
 
Upvote 0
I did search before but now found this which seems to do the trick
Code:
Sub delandre()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    If Range("B" & i).Value = "Andrè" Then Rows(i).Delete
Next i
End Sub
Perhaps someone would confirm this is the best way. It is only Andre's row to be deleted.

Thanks
 
Upvote 0
Does the row with Andre only appear once? If so then this may be of use:

Code:
Sub test()
    Columns("A").Find(what:="Andrè", Lookat:=xlWhole).EntireRow.Delete
End Sub
 
Upvote 0
We get: Compile error. Duplicate declaration in current scope.
We already have Dim as LR. Changing LR to AR in the three instances appears to solve it.
Anyone to comment please?
 
Upvote 0
I hadn't seen your post Weaver when I posted. Yes, yours is the answer (only the one Andre).
As my bridge partner says. KISS (Keep it simple stupid!)

Thanks very much
Gilbert
 
Upvote 0
This is exactly the answer that I needed today! Thanks, Weaver!
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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