ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete rows containing "ISA" in column A only, starting from row 6 (https://www.excelbanter.com/excel-programming/393099-delete-rows-containing-isa-column-only-starting-row-6-a.html)

iansmigger

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)

Incidental

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



Dave Peterson

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


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com