LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Help on cleaning / speeding up code

Hi guys,

I have the following code that cleans up a text imported file.
All it does is get rid of lines that contain the find criteria.
This works great but its slow (62k lines in the file and lots of
instances of the crap lines)


Sub DeleteUnwantedLines()
Application.ScreenUpdating = False
Dim lastcell As Range, FoundCell As Range


Do
Set FoundCell = Cells.Find(What:="severn", LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Range(FoundCell.Address).EntireRow.Delete
Else
Exit Do
End If
Loop
Do
Set FoundCell = Cells.Find(What:="Cost", LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Range(FoundCell.Address).EntireRow.Delete
Else
Exit Do
End If
Loop
Do
Set FoundCell = Cells.Find(What:="----", LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Range(FoundCell.Address).EntireRow.Delete
Else
Exit Do
End If
Loop
Do
Set FoundCell = Cells.Find(What:="Actual", LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Range(FoundCell.Address).EntireRow.Delete
Else
Exit Do
End If
Loop
Do
Set FoundCell = Cells.Find(What:="ERP ", LookAt:=xlPart)
If Not FoundCell Is Nothing Then
Range(FoundCell.Address).EntireRow.Delete
Else
Exit Do
End If
Loop

Call DeleteUnused
Application.ScreenUpdating = True
End Sub

Anyone have any ideas how to do this faster ???


I have another piece of ugly code that also works but is slow.
This checks to see if all values of row x columns B-G are 0 and if so
delete the entire row.

Sub Delete0ValueRows()

ris = mrows
Application.ScreenUpdating = False
Do While ris < 0
If Range("B" & ris).Value = "0" And Range("C" & ris).Value =
"0" And _
Range("D" & ris).Value = "0" And Range("E" & ris).Value = "0"
And _
Range("F" & ris).Value = "0" And Range("G" & ris).Value = "0"
Then
Range("A" & ris).EntireRow.Delete
End If
ris = ris - 1
Loop
Call DeleteUnused
Application.ScreenUpdating = True
End Sub

Thanks for the help...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Speeding Up Code [email protected] Excel Programming 8 August 31st 05 04:46 PM
Need help Cleaning up Code Joel Mills Excel Programming 5 December 16th 04 10:36 PM
Online Resources for Speeding Up Code orekin Excel Programming 1 July 8th 04 04:09 AM
Help with shortening/cleaning some code please roy Excel Programming 3 June 3rd 04 11:49 PM
VBA Code -- Cleaning Data Craig[_8_] Excel Programming 2 December 12th 03 12:21 AM


All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"