PDA

View Full Version : Solved: Delete range based on cell value



mlindenbach
05-13-2011, 08:42 AM
I have a spreadsheet that has a bunch of different charts / calculations on it. The charts track the top errors reported so I would like the code to think "IF cell value is greater than 40% then select range A:B, delete and move up" All I have been able to find is deleting the entire row but I only want the values in rows A & B to be deleted. There are about 60 lines of data to sort through so there would need to be a loop or something built in.

Any assistance would be greatly appreciated!

Thanks,

Melissa

Bob Phillips
05-13-2011, 09:11 AM
Public Sub ProcessData()
Dim Lastrow As Long
Dim i As Long

Application.ScreenUpdating = False

With ActiveSheet

Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = Lastrow To 2 Step -1

If .Cells(i, "B").Value > 0.4 Then

.Cells(i, "A").Resize(, 2).Delete shift:=xlShiftUp
End If
Next i
End With

Application.ScreenUpdating = True
End Sub

mlindenbach
05-13-2011, 09:17 AM
Thank you so much! Fast response and worked perfectly!!!!