Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting all rows that match a pattern


OOPS! POOR SYNTAX... THIS WORKS... THANKS, FRANK


'---------------------------------------------------------------------------
Sub DeleteRowsContaining(targetText As String, targetColumn As Long)
'---------------------------------------------------------------------------
' Function: Conditionally remove rows
' Synopsis: Calculates the number of rows
' Loops backwards through each row testing if same
' as previous
' Assumptions: The data is sorted, if not add sort to code
' Author: based on code by Bob Phillips, original version:
' http://www.xldynamic.com/source/xld.Deletingv1.html
' modified by Eliezer Broder, 10/27/04
'---------------------------------------------------------------------------
Dim cRows As Long
Dim i As Long

'first, count the rows to operate on
cRows = Cells(Rows.Count, targetColumn).End(xlUp).Row

For i = cRows To 2 Step -1
'check if current row matches the "target text"
If InStr(6, (Cells(i, targetColumn).Value), "66") Then
Cells(i, targetColumn).EntireRow.Delete
End If
Next i

End Su

--
Laze
-----------------------------------------------------------------------
Lazer's Profile: http://www.excelforum.com/member.php...nfo&userid=750
View this thread: http://www.excelforum.com/showthread.php?threadid=27287

Reply
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
Deleting Rows in A Pattern DyingIsis Excel Discussion (Misc queries) 1 May 30th 08 10:23 PM
Deleting Rows in a Pattern DyingIsis Excel Discussion (Misc queries) 0 May 29th 08 03:08 PM
Deleting Rows In A Pattern DyingIsis Excel Discussion (Misc queries) 0 May 28th 08 04:21 PM
Deleting all rows that match a pattern Lazer[_12_] Excel Programming 0 October 27th 04 06:35 PM
Deleting all rows that match a pattern Lazer[_11_] Excel Programming 1 October 27th 04 05:42 PM


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

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

About Us

"It's about Microsoft Excel"