ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Delete data in cells that don't meet criteria (https://www.excelbanter.com/new-users-excel/93262-delete-data-cells-dont-meet-criteria.html)

SITCFanTN

Delete data in cells that don't meet criteria
 
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

Paul B

Delete data in cells that don't meet criteria
 
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

"SITCFanTN" wrote in message
...
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





All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com