#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
How can I insert and delete rows within a locked cell range column Gordon Cole Excel Worksheet Functions 0 October 1st 06 11:30 AM
To delete rows when more than one cell is blank [email protected] Excel Worksheet Functions 4 September 27th 06 10:49 PM
Delete empty rows with cell type 2 FrankNL Excel Discussion (Misc queries) 1 May 3rd 06 11:10 AM
Hide/Delete entire rows based in the content of one cell Clueless Excel Discussion (Misc queries) 2 October 3rd 05 02:40 PM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"