Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Delete rows containing "ISA" in column A only, starting from row 6

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)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Delete rows containing "ISA" in column A only, starting from row 6

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Delete rows containing "ISA" in column A only, starting from row 6

One mo

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
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
How do I replace decimals starting with "." to "0." in excel? Julio Excel Discussion (Misc queries) 2 November 1st 08 07:48 AM
Delete Rows that Contain the Text "Total" and vice versa SteveC Excel Programming 7 January 25th 06 07:11 PM
Search for the word "continued", if found, delete that row + 10 rows above jriendeau5[_4_] Excel Programming 0 November 5th 04 03:00 PM
Search for the word "continued", if found, delete that row + 10 rows above jriendeau5 Excel Programming 1 November 5th 04 02:24 AM
Search "Total" in all worksheets and delete rows containing "Total" mk_garg20 Excel Programming 2 July 30th 04 06:42 AM


All times are GMT +1. The time now is 07:10 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"