VBA Delete rows that are not divisible by 50

  • I have many worksheets with sequential linear xy data that vary in length. I am looking for vba automation to delete (rows up) all data with the exception of x data (A) that is divisible by 50


    My macro produces a helper column that flags the data appropriately through formula. The Autofilter selects the the flags and deletes. I would like to make this dynamic and be able to change the divisor to 100 or 200 through the code. Here's what my macro looks like.

  • Re: VBA Delete rows that are not divisible by 50


    Use the MOD() function in the helper column and refer to another cell that contains the number you want to use as the divisor...


    For example:
    A1 contains the divisor.
    C2 contains the formula
    [bfn]=(MOD(A2, $A$1)=0)[/bfn]


    However, that "...IF((OR((RIGHT(RC[-2],2)=" makes me wonder exactly what is in Col A

  • Re: VBA Delete rows that are not divisible by 50


    Appreciate the suggestion cytop. Here is the final code:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!