ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete row on basic of cell (https://www.excelbanter.com/excel-programming/406103-delete-row-basic-cell.html)

BOSS

delete row on basic of cell
 
HI,

I wish to delete entire row if value in col J is "--"

I did some work but not working properly.
data id huge of 400 rows.

Thanks for help.
Boss


Sub delete()
Dim rng As Range
Dim rngAll As Range

Set rngAll = Range("j:j")

For Each rng In rngAll
If rng.Value = "--" Then

rng.EntireRow.Delete
End If
Next rng

Set rng = Nothing
Set rngAll = Nothing

End Sub


Gary''s Student

delete row on basic of cell
 
Sub marine()
Set rngAll = Intersect(Range("i:j"), ActiveSheet.UsedRange)
Set rdel = Nothing
For Each r In rngAll
If r.Value = "--" Then
If rdel Is Nothing Then
Set rdel = r
Else
Set rdel = Union(rdel, r)
End If
End If
Next
If rdel Is Nothing Then
Else
rdel.EntireRow.Delete
End If
End Sub

--
Gary''s Student - gsnu200769


"Boss" wrote:

HI,

I wish to delete entire row if value in col J is "--"

I did some work but not working properly.
data id huge of 400 rows.

Thanks for help.
Boss


Sub delete()
Dim rng As Range
Dim rngAll As Range

Set rngAll = Range("j:j")

For Each rng In rngAll
If rng.Value = "--" Then

rng.EntireRow.Delete
End If
Next rng

Set rng = Nothing
Set rngAll = Nothing

End Sub



All times are GMT +1. The time now is 12:01 AM.

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