Deletion macro

rooster06

New Member
Joined
Mar 21, 2019
Messages
1
Hello forum

I'm new here s apologies f I don't get his right, I have a macro code that deletes rows if a cell in column A contains "/C/, but runs a little slow, the code is below. Would anybody be able to improve on this please

Thanks in advance

SubCat()

Application.ScreenUpdating= False
Application.EnableEvents= False
Application.DisplayAlerts= False
Dim c As Range
Dim SearchString

Set SearchString = Range("A1",ActiveSheet.Range("A85000").End(xlUp))
Do
Set c = SearchString.Find("/C/", LookIn:=xlValues)
If Not c Is Nothing Then c.EntireRow.Delete
Loop While Not c Is Nothing
MsgBox("Finished")

Application.ScreenUpdating= True
Application.EnableEvents= True
Application.DisplayAlerts= True

EndSub


Rooster
 

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.
Hi & welcome to MrExcel
How about
Code:
Sub rooster06()
   With ActiveSheet
      .Range("A1").AutoFilter 1, "*/C/*"
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
The * are wildcards, so the filter is looking for cells that contain /C/ amongst other tex, rather than cells that only have /C/ in them
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,331
Latest member
smckenzie2016

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