Hello. I'm trying to modify a piece of code to suit my own purposes, but just can't get it to work properly.

Basically, I have 3 worksheets in a workbook. I want VBA code to run in 1 of the worksheets and clear the contents of the row (not delete entire rows) from B to to AP if the key in column A exists in either of the two other worksheets.

The equivalent Excel formula which identifies this properly for me is: =IF(COUNTIF(Weekly!A:A,A2)>0,TRUE,IF(COUNTIF(Daily!D:D,A2)>0,TRUE))

So I want to somehow use the formula above in place of the "ABC"/"DEF" formula in the code below, and also replace the "ActiveSheet.Rows(x).Delete" with a command to just clear the contents from column B to AP.

ALL help appreciated !!!

Dim x As Integer

x = 1

Do While x <= ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row

    If (Cells(x, 12) = "ABC") Then
    ActiveSheet.Rows(x).Delete
    Else
        If (Cells(x, 27) <> "DEF") And (Cells(x, 27) <> "") Then
        ActiveSheet.Rows(x).Delete
        Else
        x = x + 1
        End If
    End If

Loop

End Sub