Find and delete row

  • Thread starter Thread starter Eva Shanley
  • Start date Start date
E

Eva Shanley

Hello, and a happy St. Pat's day to all,
I need to find the row in Col. A that contains the
text "Grand", and then delete the entire row. I've tried
creating some code that doesn't work, so all help I can
get is greatly appreciated! TIA
 
Hi
try the following macro

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "Grand" Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub
 
...
Hello, and a happy St. Pat's day to all,
I need to find the row in Col. A that contains the
text "Grand", and then delete the entire row. I've tried
creating some code that doesn't work, so all help I can
get is greatly appreciated! TIA


Eva,

This is one method.

Sub ClearGrand()
Dim rnCell As Range
Dim iRows As Integer
Dim iCounter As Integer
Dim rnActiveRegion

Set rnActiveRegion = Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))

iRows = rnActiveRegion.Rows.Count

For iCounter = iRows To 1 Step -1
If UCase(rnActiveRegion(iCounter, 1).Value) = UCase("grand") Then
rnActiveRegion(iCounter, 1).EntireRow.Delete
End If
Next
End Sub

Best,
Kevin
 
Thanks to both Kevin and Frank for the solutions to my
problem! If it weren't for this User Group I'd be in big
trouble!
 
Thanks to both Kevin and Frank for the solutions to my
problem! If it weren't for this User Group I'd be in big
trouble!

On behalf of Frank, let me write "our pleasure."

Best regards,
Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top