Clear Column Contents Based on Criteria

  • I have 7 columns - E,F,G,H,J,K,L that have either a 1 or 0 value with a sum formula at the bottom of the column.

    I would like to create a script to clear the contents of those columns but leave the formulas and also remove the data in the row's of M,N,O

    I have gone throught the clear contents threads but I am lost.

    Thanks for all your help.


  • Hi,

    here's an example, this should give you a start:

    Dim lngRow As Long
    Dim lngStartRow As Long
    lngStartRow = 2 'Starting row
    lngRow = lngStartRow
    Do While Left(ActiveWorkbook.ActiveSheet.Range("E" & lngRow).Formula, 1) <> "=" 'Search until formule
    lngRow = lngRow + 1
    ActiveWorkbook.ActiveSheet.Range("E" & lngStartRow & ":L" & lngRow - 1).ClearContents
  • Re: Clear contents in Column based on criteria

    Thanks Gollem got the data in the columns to clear!! Now I am having probelms getting it to clear off the data in Columns M-O where there is data in E-L. When I added my script to remove the data in M-O it is also removing the data in Column I which it is not supposed to do dont know what I did wrong.

    here is my code:

    ' My code to remove text in column M-O for every entry into column E-L with the exception Column I

    example attached

  • Re: Clear contents in Column based on criteria

    I'll take a look at it.

    Please adapt your post so that the code is bewteen code-tags, it's better to read that way.

Participate now!

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