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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
74,658
Office Version
  1. 365
Platform
  1. Windows
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:

rooster05

New Member
Joined
Mar 4, 2017
Messages
34
Fluff,

Thanks that's a lot lot quicker, just a quick question what do the * mean in the code
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
74,658
Office Version
  1. 365
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,827
Messages
5,855,878
Members
431,771
Latest member
CoryMelth

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