ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete row if value is zero (https://www.excelbanter.com/excel-programming/414353-delete-row-if-value-zero.html)

KWhamill

Delete row if value is zero
 
I'm trying to create an if statement that will delete entire rows where the
value in Column N is less than .01 or efectively zero for my purposes. The
little bit i've figured out will delete the row but only if the whole row is
blank. If any one can help me all the better.
Thank you,
Karl

Susan

Delete row if value is zero
 
======================
Option Explicit

Sub step_backwards()


Dim myLastRow As Long
Dim r As Long
Dim c As Range


myLastRow = ActiveSheet.Cells(10000, 1).End(xlUp).Row


For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("a" & r)
If c.Value = "" Then
c.EntireRow.Delete
End If
Next r


End Sub
=========================
it looks for blanks in column A. change that if you need to.
hope it helps
:)
susan




On Jul 21, 10:05*am, KWhamill
wrote:
I'm trying to create an if statement that will delete entire rows where the
value in Column N is less than .01 or efectively zero for my purposes. The
little bit i've figured out will delete the row but only if the whole row is
blank. If any one can help me all the better.
Thank you,
Karl



Don Guillett

Delete row if value is zero
 
ALWAYS post your efforts for comments

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KWhamill" wrote in message
...
I'm trying to create an if statement that will delete entire rows where
the
value in Column N is less than .01 or efectively zero for my purposes. The
little bit i've figured out will delete the row but only if the whole row
is
blank. If any one can help me all the better.
Thank you,
Karl



KWhamill

Delete row if value is zero
 
Thank you that was great Now i see what i was doing wrong.
R,
Karl

"Susan" wrote:

======================
Option Explicit

Sub step_backwards()


Dim myLastRow As Long
Dim r As Long
Dim c As Range


myLastRow = ActiveSheet.Cells(10000, 1).End(xlUp).Row


For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("a" & r)
If c.Value = "" Then
c.EntireRow.Delete
End If
Next r


End Sub
=========================
it looks for blanks in column A. change that if you need to.
hope it helps
:)
susan




On Jul 21, 10:05 am, KWhamill
wrote:
I'm trying to create an if statement that will delete entire rows where the
value in Column N is less than .01 or efectively zero for my purposes. The
little bit i've figured out will delete the row but only if the whole row is
blank. If any one can help me all the better.
Thank you,
Karl





All times are GMT +1. The time now is 08:50 PM.

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