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: 82
Default VBA Question - Is there a better approach?

Below is a piece of code I use to delete rows that contain a specific keyword
in a designated column. Right now I specify the range m2:m1500, but rarely
have that many lines in the raw data. I chose the number 1500 to be sure the
code runs on all lines. Right now this is the largest time contributor to
the macro I run on the data, of which this is a small part.

Is there an approach I can follow other than the one shown below that
addresses the speed, and would also not require me to specify the range... so
it acts only the actual number of row of data in the worksheet?

Thanks,

Scott



'----------------------------------------------------
'Delete extra lines
'----------------------------------------------------
myWords = Array("2")

Set wks = ActiveSheet
With wks
With .Range("m2:m1500")
For iCtr = LBound(myWords) To UBound(myWords)
Do
Set FoundCell = .Cells.Find(What:=myWords(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
Loop
Next iCtr
End With
End With
 
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
Formula/Approach Question carl Excel Worksheet Functions 1 November 9th 07 04:47 PM
What is the right approach? Epinn Excel Worksheet Functions 3 October 8th 06 12:22 PM
How to approach this? mevetts Excel Discussion (Misc queries) 1 January 10th 06 04:20 PM
New approach davegb Excel Programming 6 December 6th 05 04:31 PM
How do I approach this? Grant Reid Excel Programming 5 May 25th 04 04:51 PM


All times are GMT +1. The time now is 06:29 AM.

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"