PC Review


Reply
Thread Tools Rate Thread

how to delete a row based on a condition

 
 
ya
Guest
Posts: n/a
 
      17th Dec 2008
how to delete a row based on a condition
 
Reply With Quote
 
 
 
 
Noob McKnownowt
Guest
Posts: n/a
 
      17th Dec 2008


"ya" wrote:

> how to delete a row based on a condition


If you could provide us with a little more information that would help, but
a general answer would be somethin like;

Sub DelRow()

Dim Rng as Range
Dim Cell as Range

set Rng = Sheet("the sheet you want to check").Range(The range on the sheet
you want to search. i.e. "D")

For Each Cell in Rng
If Cell.Value = "what you want to search for" Then
Cell.EntireRow.Delete
End If
Next Cell

End Sub

HTH,

The Noob
 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      17th Dec 2008
Private Sub deleterows()
Dim rng As Range
Dim i As Long

Set rng = ActiveSheet.Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))

'Work backwards from bottom to top when deleting rows
'This will delete the row if cell value = 0
'change 0 to your needs
With rng
For i = .Rows.Count To 1 Step -1
If .Cells(i) = 0 Then
.Cells(i).EntireRow.Delete
End If
Next i
End With
End Sub

"ya" wrote:

> how to delete a row based on a condition

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to delete rows based on a condition marcia2026 Microsoft Excel Programming 9 31st Oct 2009 10:54 AM
Delete Rows based on condition Vic Microsoft Excel Misc 2 18th Aug 2009 08:54 PM
Delete rows based on more than one condition. thomas Microsoft Excel Programming 3 24th Sep 2008 02:20 PM
Delete row 1 based on condition in cell on row 2 McDuck Microsoft Excel Worksheet Functions 0 30th Jul 2008 07:53 PM
How to delete a data row based on a condition =?Utf-8?B?d21j?= Microsoft Excel New Users 4 18th Apr 2007 02:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.