Creating a Macro that will Delete if anything less than 20%

  • Thread starter Thread starter Julienne
  • Start date Start date
J

Julienne

Hi I wanted to know what the code would be to delete an entire row if
that cells column H is less than 20.0%. Then after that, if column I
is less than 20% delete those rows. I appreciate your help. Thanks
 
Try this out

Range("a1").Select
Do Until ActiveCell = ""

If ActiveCell.Offset(columnoffset:=11) < 0.2 Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(rowoffset:=1).Activate
End If

Loop

Range("A1").Select

Do Until ActiveCell = ""

If ActiveCell.Offset(columnoffset:=8) < 0.2 Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(rowoffset:=1).Activate
End If
Loop
 
The code doesnt work because it loops and doesn't stop unless i hi
ctrl- break. not sure how to change
 
Have you posted the code (I can't find it...)? If not, please do so.
 
Copy and paste this into a macro and run it

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "H").Value <= 20 Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Su
 

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