Delete data in cells that don't meet criteria

S

SITCFanTN

I'm not sure how I would code deleting any data in the cells in Column "Type"
if it is not "HO". The report I download sometimes puts odd letters in cells
in this column and I just want to clear it out rather than scan this very
long report and delete manually. I will put the code in an existing macro.
Thank you
 
P

Paul B

sitcfantn, here is one way

Sub Delete_HO()

Dim iRow As Long
Dim SpecValue As String

SpecValue = "HO"

If SpecValue = "" Then Exit Sub

For iRow = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If Cells(iRow, 1) = SpecValue Then Rows(iRow).Delete
Next iRow

End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top