View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark[_66_] Mark[_66_] is offline
external usenet poster
 
Posts: 24
Default combining multiple find/replace subs

Hello

I have about 7 or 8 subs for finding and replacing after a huge amount
of .txt files have been searched for "href." They are meant for
extracting the data that I actually need. The only thing is, is that
the report I created with them in there takes way too long, almost an
hour. Is there a way to combine these or somehow speed up their
processing speed? Here are a couple examples, they are searching
through about 45,000 rows.

Sub DeleteRowsImg()

Dim r As Long
'Dim ans As String
Dim c As Range
Dim lrow As Long

'ans = InputBox("What string do you want rows to be deleted if they
contain it?")
Application.ScreenUpdating = False

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For r = lrow To 1 Step -1
With Cells(r, 2)
Set c = .Find("img", LookIn:=xlValues)
If Not c Is Nothing Then
.EntireRow.Delete
End If
End With
Next r
Application.ScreenUpdating = True

End Sub

Sub DeleteRowsAboutus()

Dim r As Long
'Dim ans As String
Dim c As Range
Dim lrow As Long

'ans = InputBox("What string do you want rows to be deleted if they
contain it?")
Application.ScreenUpdating = False

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For r = lrow To 1 Step -1
With Cells(r, 2)
Set c = .Find("aboutus", LookIn:=xlValues)
If Not c Is Nothing Then
.EntireRow.Delete
End If
End With
Next r
Application.ScreenUpdating = True

End Sub