ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete rows on Cell (https://www.excelbanter.com/excel-discussion-misc-queries/170952-delete-rows-cell.html)

wal50

Delete rows on Cell
 
this group led me to C. Pearson's site and this most helpful macro:

Public Sub DeleteRowOnBlankCell()

On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete
ActiveSheet.UsedRange

End Sub

How can I modify this to delete on Cell = 0?
I looked at other postings and they are all limited to specific columns. I
would like to have a general solution so that whichever column is selected is
used.
Thanks in advance,
wal50

Gary''s Student

Delete rows on Cell
 
Sub zero_killer()
Set killrow = Nothing
For Each rr In Selection
If IsEmpty(rr) Then
Else
If rr.Value = 0 Then
If killrow Is Nothing Then
Set killrow = rr
Else
Set killrow = Union(killrow, rr)
End If
End If
End If
Next

If killrow Is Nothing Then
Else
killrow.EntireRow.Delete
End If
End Sub

--
Gary''s Student - gsnu200762


"wal50" wrote:

this group led me to C. Pearson's site and this most helpful macro:

Public Sub DeleteRowOnBlankCell()

On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete
ActiveSheet.UsedRange

End Sub

How can I modify this to delete on Cell = 0?
I looked at other postings and they are all limited to specific columns. I
would like to have a general solution so that whichever column is selected is
used.
Thanks in advance,
wal50


Gord Dibben

Delete rows on Cell
 
Public Sub DeleteRowOnCell()
Dim coltocheck As Range
Set coltocheck = Application.InputBox(prompt:= _
"Select A Column", Type:=8)
With coltocheck
Do
Set c = .Find(0, LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False)
If c Is Nothing Then Exit Do
c.EntireRow.Delete
Loop
End With
End Sub


Gord Dibben MS Excel MVP

On Fri, 28 Dec 2007 11:31:01 -0800, wal50
wrote:

this group led me to C. Pearson's site and this most helpful macro:

Public Sub DeleteRowOnBlankCell()

On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
ActiveSheet.UsedRange

End Sub

How can I modify this to delete on Cell = 0?
I looked at other postings and they are all limited to specific columns. I
would like to have a general solution so that whichever column is selected is
used.
Thanks in advance,
wal50



wal50

Delete rows on Cell
 
Thank you both for the responses. This is is a very helpful site.
wal50

"Gord Dibben" wrote:

Public Sub DeleteRowOnCell()
Dim coltocheck As Range
Set coltocheck = Application.InputBox(prompt:= _
"Select A Column", Type:=8)
With coltocheck
Do
Set c = .Find(0, LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False)
If c Is Nothing Then Exit Do
c.EntireRow.Delete
Loop
End With
End Sub


Gord Dibben MS Excel MVP

On Fri, 28 Dec 2007 11:31:01 -0800, wal50
wrote:

this group led me to C. Pearson's site and this most helpful macro:

Public Sub DeleteRowOnBlankCell()

On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
ActiveSheet.UsedRange

End Sub

How can I modify this to delete on Cell = 0?
I looked at other postings and they are all limited to specific columns. I
would like to have a general solution so that whichever column is selected is
used.
Thanks in advance,
wal50





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

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