Delete row if value between two numbers

pook_666

Board Regular
Joined
Aug 16, 2018
Messages
94
Hi magicians,

I'm trying to delete rows if the value in column E is between -0.01 and 0.01...unfortunately I can't just delete if it is simply 0 as there are rounding's to many millions after the decimal point so have to do between -0.01 and 0.01 to remove anything for 0.00.

I thought about just using the "and" between the IF statement as per below, but VBA doesn't like it.....any ideas? Thanks!

VBA Code:
    lrow2 = Cells(Rows.Count, "B").End(xlUp).Row
    For i = lrow2 To 1 Step -1
        If Cells(i, "E") >-0.01 and <0.01 Then
            Rows(i).Delete
        End If
    Next i
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello Pook_666,

A slight change to your code should work:-

VBA Code:
Sub Test()

Dim lrow2 As Long: lrow2 = Cells(Rows.Count, "B").End(xlUp).Row

        For i = lrow2 To 1 Step -1
                If Cells(i, "E") > -0.01 And Cells(i, "E") < 0.01 Then
                       Rows(i).Delete
                End If
        Next i
End Sub

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Solution
You're welcome Pook_666. I'm glad to have been able to assist and thanks for the feed-back.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top