Hello,
I have a spreadsheet with data in column A. Rows 1 to 16 are filled with header information and a linest function. Since the linest function does not exclude hidden cells I need a macro that will delete the row if the cell value is less than my input criteria from F1 and also if the value is greater than the value in F2.
I have tried the below code (butchered from another site) but 1 it is slow (not really a problem) and 2 on the second pass it deletes the data in rows 1 to 16. If anyone can help with this task I would very much appreciate it.
Thanks,
Craig
I have a spreadsheet with data in column A. Rows 1 to 16 are filled with header information and a linest function. Since the linest function does not exclude hidden cells I need a macro that will delete the row if the cell value is less than my input criteria from F1 and also if the value is greater than the value in F2.
I have tried the below code (butchered from another site) but 1 it is slow (not really a problem) and 2 on the second pass it deletes the data in rows 1 to 16. If anyone can help with this task I would very much appreciate it.
Thanks,
Craig
Code:
Sub del()
' Turn off screen updating.3
Application.ScreenUpdating = False
Dim LR As Long, i As Long, j As Long, LR2 As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
If Range("A" & i).Value <= Range("F1") Then Rows(i).EntireRow.Delete
Next i
LR2 = Range("A" & Rows.Count).End(xlUp).Row
For j = LR2 To 1 Step -1
If Range("A" & j).Value >= Range("F2") Then Rows(j).EntireRow.Delete
Next j
End Sub