View Full Version : Solved: Delete row
oleg_v
05-04-2010, 07:04 AM
Hello
I need some help.
i need a macro that will delete entire row if cells value in column "B"
is greater than 0.01
the macro need to check each cell in column"B"
Thanks
Oleg
Bob Phillips
05-04-2010, 07:26 AM
Try
Public Sub ProcessData()
Const TEST_COLUMN As String = "B" '<=== change to suit
Dim LastRow As Long
Dim rng As Range
With ActiveSheet
.Rows(1).Insert
.Cells(1, TEST_COLUMN).Value2 = "Temp"
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
Set rng = .Cells(1, TEST_COLUMN).Resize(LastRow)
rng.AutoFilter Field:=1, Criteria1:=">0.01"
On Error Resume Next
Set rng = rng.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete
End With
End Sub
bubbapost
05-04-2010, 08:51 AM
Or you can try this:
Sub DeleteRow()
Dim i As Integer
Dim FinalRow As Integer
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row
For i = FinalRow To 1 Step -1
If Cells(i, 2) > 0.01 Then
Cells(i, 2).EntireRow.Delete
End If
Next i
End Sub
oleg_v
05-04-2010, 11:56 PM
thanks
great
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.