PC Review


Reply
Thread Tools Rate Thread

Delete rows containing "ISA" in column A only, starting from row 6

 
 
=?Utf-8?B?aWFuc21pZ2dlcg==?=
Guest
Posts: n/a
 
      11th Jul 2007
I am looking for a macro to delete all rows in column A only that contain the
word "ISA", starting at row 6 and ending at the bottom of the data (variable)
 
Reply With Quote
 
 
 
 
Incidental
Guest
Posts: n/a
 
      11th Jul 2007
Hi

The code below would be one way to do it

Option Explicit
Dim MyCell, MyRng As Range
Dim LstRow As Integer

Private Sub CommandButton1_Click()

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A6:A" & LstRow)

For Each MyCell In MyRng

If MyCell.Value = "ISA" Then

MyCell.EntireRow.Delete

End If

Next MyCell

End Sub

hope this helps

S


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Jul 2007
One more:

Option Explicit
Sub testme02()

Dim myRng As Range
Dim FoundCell As Range
Dim wks As Worksheet
Dim myStrings As Variant
Dim iCtr As Long

myStrings = Array("ISA") 'add more strings if you need

Set wks = ActiveSheet

With wks
Set myRng = .Range("a6:a" & .Rows.Count)
End With

For iCtr = LBound(myStrings) To UBound(myStrings)
Do
With myRng
Set FoundCell = .Cells.Find(what:=myStrings(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
End With
Loop
Next iCtr
End Sub

iansmigger wrote:
>
> I am looking for a macro to delete all rows in column A only that contain the
> word "ISA", starting at row 6 and ending at the bottom of the data (variable)


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete rows if cell in row contains "a" or "o" or empty bartman1980 Microsoft Excel Programming 2 4th Nov 2007 08:20 PM
delete rows with null values in "M" column =?Utf-8?B?SmFuaXM=?= Microsoft Excel Programming 5 18th Jul 2007 09:48 PM
Trying to delete "=" sign at end of text column if there is an "=" in the field Kent Microsoft Excel Worksheet Functions 0 19th Feb 2004 05:34 PM
Re: Trying to delete "=" sign at end of text column if there is an "=" in the field Frank Kabel Microsoft Excel Worksheet Functions 0 19th Feb 2004 05:17 PM
Re: Trying to delete "=" sign at end of text column if there is an "=" in the field Dave R. Microsoft Excel Worksheet Functions 0 19th Feb 2004 05:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 PM.