Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default delete row on based on cell value

If a cell contains a certain value, I want to delete the row it is in, e.g.,
if cell K2 has value 0 then delete row 2
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default delete row on based on cell value

Public Sub ProcessData()
Const TEST_COLUMN As String = "K" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow to 1 Step -1
If .cells(i, TEST_COLUMN).Value = 0 Then
.Rows(i).Delete
End If
Next i
End With

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"GKW in GA" wrote in message
...
If a cell contains a certain value, I want to delete the row it is in,
e.g.,
if cell K2 has value 0 then delete row 2



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
Is there a way to delete a cell value based on a condition? Peanut Excel Discussion (Misc queries) 2 October 2nd 06 09:55 PM
Delete Row based off cell content Chuck Neal Excel Discussion (Misc queries) 3 March 29th 06 08:52 PM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM
Delete record(s) in other cells based on value of one cell. MPope Excel Discussion (Misc queries) 1 October 12th 05 06:57 PM


All times are GMT +1. The time now is 07:09 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"