Use macro to delete rows. RRS feed

  • Question

  • Greetings all!

    I have a question that I hope someone might be able to help with.

    I'm trying to create a macro that will delete all of the rows in a table that have a cell containing a certain value. Let me explain...

    Cell B2 contains a number.

    The range of cells (E3:E500) also contains numbers.

    I'm trying to create a macro that has an IF function which would delete the entrie rows of any cells in the (E3:E500) range, that contains a number which is less than the number in cell B2.

    I know that in principal this shouldn't be that hard, yet try as i might, i can't seem to get it work!

    Thank you in advance for any help!




    Thursday, December 1, 2011 7:19 PM


  • hi Pete,
    For i = Range("E65536").End(xlUp).Row To 3 Step -1
     If Range("E" & i) < Range("B" & i) Then Rows(i).Delete Shift:=xlUp
    ' or
    'If Range("E" & i) < Range("B2") Then Rows(i).Delete Shift:=xlUp ' i'm not sure
    Thursday, December 1, 2011 7:47 PM