Delete Rows based on criteria in Column A (not working)

  • Thread starter Thread starter Mslady
  • Start date Start date
M

Mslady

I am trying to put additional functionality in this code to delete row
with "3/25/2005" or "12/31/2004" in column A.

This doesn't work, yet it doesn't give any errors.
When i check my sheet, it deletes duplicate rows but not the rows wit
"3/25/2005" or "12/31/2004".
Please can anyone take a look? Thanks


Code
-------------------

'DELETE DUPLICATE ROWS AND DELETE ROWS WITH CRITERIA
Dim i As Long
Dim cursheet As Worksheet
Set cursheet = Worksheets("DataTable")
For i = cursheet.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(cursheet.Range(cursheet.Cells(2, 1), cursheet.Cells(i, 1)), cursheet.Cells(i, 1)) > 1 Or _
Cells(i, "A").Value = "3/25/2005" Or _
Cells(i, "A").Value = "12/31/2004" Then
cursheet.Cells(i, 1).EntireRow.Delete
End If
Next i
 
Hi Kleev,
I tried again, still no luck.

It works when i put it in my module, but not when i put it in my sheet
Any ideas
 

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

Back
Top