View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kai[_2_] Kai[_2_] is offline
external usenet poster
 
Posts: 1
Default Deleting a row based on a value in a column

Hi there!

Over the past few days I've been working on a workflow system in Excel.

One of the features that was wanted is a clear down function, which will
automatically delete all off the rows with "Y" in Sheets("Work") columns H
and I.

The only thing is I can't seem to get any form of my code to work...

The majority of snippets that require listing values in certain rows I just
just the for each cell in rows, if cell.value2 = data then object.additem...
etc.

Could someone help me with this code and let me know how I can make it
workable?

Private Sub run_cleardown_Click()
Dim data As String
data = "Y"
For Each cell In Sheets("Work").Range("H:H")
If cell.Value2 = data Then
EntireRow.Delete cell.Value2
Else
End If
Next
For Each cell In Sheets("Work").Range("I:I")
If cell.Value2 = data Then
EntireRow.Delete cell.Value2
Else
End If

End Sub

Thanks!

Kai