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
 

Some videos you may like

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
46,352
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
46,352
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,054
Messages
5,526,510
Members
409,705
Latest member
MB1984

This Week's Hot Topics

Top