Reputation: 256
I am looking for a simple line of VBA that erases certain cells when other cells equals a certain value.
The following code works great with Text and Numeric value, but it fails to check and clear the cells if the value equals a percentage.
Sub Module1()
If Range("C5").Value Like "Done" And Range("D5").Value = "100%" Then
Range("B5").ClearContents
End If
End Sub
It still doesn't work if I remove the % sign from the D5 Value checkup. The cell itself is Formatted as a Percentage.
Upvotes: 3
Views: 274
Reputation: 152535
A percentage is a number formatted like text.
Change
Range("D5").Value = "100%"
to its decimal value.
Range("D5").Value = 1
Upvotes: 2