ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete rows depending on cell Value (https://www.excelbanter.com/excel-programming/390962-delete-rows-depending-cell-value.html)

Tomas Stroem

Delete rows depending on cell Value
 
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?
--
Tomas S

Norman Jones

Delete rows depending on cell Value
 
Hi Tomas,

Are the 'summary fields' always found in the last data row?


---
Regards,
Norman


"Tomas Stroem" wrote in message
...
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?
--
Tomas S




Tomas Stroem

Delete rows depending on cell Value
 
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.
--
Tomas S


"Norman Jones" wrote:

Hi Tomas,

Are the 'summary fields' always found in the last data row?


---
Regards,
Norman


"Tomas Stroem" wrote in message
...
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?
--
Tomas S





Mike H

Delete rows depending on cell Value
 
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

"Tomas Stroem" wrote:

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.
--
Tomas S


"Norman Jones" wrote:

Hi Tomas,

Are the 'summary fields' always found in the last data row?


---
Regards,
Norman


"Tomas Stroem" wrote in message
...
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?
--
Tomas S






All times are GMT +1. The time now is 03:05 PM.

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