Invalid validation syntax. Right:
If Cells(i, 3).Value <> "Deal" Or Cells(i, 3).Value <> "Meal" Or Cells(i, 3).Value <> "Run" Then
So correct in terms of syntax, but incorrectly logically. The Or operator is used. With such a record can not be the result False .
Examples
In the cell, the word " Deal ":
"Deal" <> "Deal" Or "Deal" <> "Meal" = False + True = True
In the cell " Excel ":
"Excel" <> "Deal" Or "Excel" <> "Meal" = True + True = True
In this case, you need to use the operator And ( And ).
===========================
We look through lines 3 through 25. If the value in the cell of column C is not equal to the specified one, we clear the cell. Instead of And , the If cascade allows you to cut off extra calculations.
Sub DelVal1() Dim i As Long For i = 3 To 25' цикл по строкам If Cells(i, 3).Value <> "Deal" Then If Cells(i, 3).Value <> "Meal" Then If Cells(i, 3).Value <> "Run" Then Cells(i, 3).ClearContents End If End If Next i End Sub
The cell value can be searched for in a text composed of the search words:
Sub DelVal2() Dim i As Long For i = 3 To 25 If Not ("DealMealRun" Like "*" & Cells(i, 3).Value & "*") Then _ Cells(i, 3).ClearContents Next i End Sub
If there are many words, it makes sense to add them to the array:
Sub DelVal3() Dim ArrVal() Dim i As Long, j As Long ArrVal = Array("Deal", "Meal", "Run") ' значения в массив For i = 3 To 25 ' цикл по строкам For j = 0 To UBound(ArrVal) ' цикл по массиву If Cells(i, 3).Value = ArrVal(j) Then Exit For Next j ' ни одно не найдено - очищаем ячейку If j = UBound(ArrVal) + 1 Then Cells(i, 3).ClearContents Next i End Sub