Delete rows depending on cell Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a problem to get a macro that deletes rows in a worksheet depending
on the value in row "AB". In the top of the sheet there are headers that i do
not want to test for and at the bottom there are some summary fields that i
do not want to test for either.
The header are always in the same place but the summary fields can vary in
position.

Doe anyone have a good suggestion on how to solve this?
 
Norman,
There are three rows with different types of summaries at the bottom. Right
now I have a blank row inserted before the summaries. This blank row is the
first after the ones in the header rows that ever will appear at the time the
macro will be run.
 
Thomas,

If I understand correctly you want to read each cell in column AB excluding
the top header rows which are a fixed location and the bottom 4 rows which
are a blank row and 3 rows with data. You then want to delete the entire row
depending on what is in those cells. If this is correct try:-

Sub deleteit()
Dim myrange As Range
lastrowcolab = Range("AB65536").End(xlUp).Row - 4
Set myrange = Range("AB10:A" & lastrowcolab)
For Each c In myrange
c.Select
If c.Value = "Q" Then '<Change to your criteria
Selection.EntireRow.Delete
End If
Next
End Sub

Mike
 

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