Code to delete rows giving mismatch error
Posted this two days ago but fear it has fallen by the wayside once off the
front page...
obs is taken from an inputbox and the msgbox returns the correct value.
Point of this is to go through the sheet row by row and delete any row where
column D does not equal twice the value of obs. I'm not completely familiar
with VBA and may well have screwed something up. "If cells (i,"D")..." line
is giving the mismatch error.
All help is much appreciated.
MsgBox "Obs value is = " & obs
For i = Cells(Rows.Count, "d").End(xlUp).Row To 2 Step -1
If Cells(i, "D") < obs * 2 Then Cells(i, "D").EntireRow.Delete
Next i
Range("D1:D65536").Select
Selection.Delete
|