ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete entire row based on cell content (https://www.excelbanter.com/excel-programming/284209-delete-entire-row-based-cell-content.html)

Phil

Delete entire row based on cell content
 
I would like to have a macro run down a column of figures,
deleting rows that contain the number 1. I'm a novice so I
have trouble instructing it to stop when the data ends....

TIA!

JMay

Delete entire row based on cell content
 
In a standard module insert:

Sub DeleteRowWith1()
Dim MyRange As Range
Set MyRange = Range("D:D")
For Each c In MyRange
If IsEmpty(ActiveCell.Value) Then
Exit Sub
Else
If c.Value = 1 Then
ActiveCell.EntireRow.Delete
End If
End If
ActiveCell.Offset(1, 0).Select
Next c
End Sub


"PHIL" wrote in message
...
I would like to have a macro run down a column of figures,
deleting rows that contain the number 1. I'm a novice so I
have trouble instructing it to stop when the data ends....

TIA!




Wazza McG

Delete entire row based on cell content
 
Sub deleterowwithoneinit()
'
' Macro1 Macro
' Macro recorded 3/12/2003 by me
'
For Each c In Worksheets("Sheet1").Range("A:A")
If c.Value = 1 Then
c.EntireRow.Delete
End If
Next

End Sub

Wazza McG




All times are GMT +1. The time now is 10:09 PM.

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