VBA to change 0 value to Blank based on criteria in another Column

  • Hello,



    Hoping someone can assist me with the following issue. In the attached, I need VBA code to delete the values in Column K that have a "0" value if the value in column C begins with "1111".
    First tab is raw data, second tab is desired results.
    Attached is a representative spreadsheet, actual spreadsheet can be many thousands of rows.
    Thanks for taking a look.


    JL

  • Try:

    Code
    Sub ClearColK()
        Application.ScreenUpdating = False
        Dim LastRow As Long
        LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Range("A1:K" & LastRow).AutoFilter Field:=3, Criteria1:="=1111*"
        Range("A1:K" & LastRow).AutoFilter Field:=11, Criteria1:="0"
        Range("K2:K" & LastRow).SpecialCells(xlCellTypeVisible).ClearContents
        If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
        Application.ScreenUpdating = True
    End Sub

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • You are very welcome. :)

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

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