LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default how to delete a row based on a condition

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

 
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
Delete Rows based on condition Vic Excel Discussion (Misc queries) 2 August 18th 09 08:54 PM
HOW CAN I DELETE A COLUMN BASED ON A CONDITION ya Excel Programming 1 December 17th 08 12:55 AM
Delete worksheet row based on condition miek Excel Programming 3 August 23rd 07 07:16 PM
How to delete a data row based on a condition wmc New Users to Excel 4 April 18th 07 02:40 PM
Delete Columns based on a condition Joel Mills Excel Programming 3 August 6th 04 07:21 PM


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

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"