Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Range("").Value = "Percentage%" Error

Tags:

excel

vba

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.

like image 386
Francis Maltais Avatar asked Jul 13 '26 21:07

Francis Maltais


1 Answers

A percentage is a number formatted like text.

Change

Range("D5").Value = "100%" 

to its decimal value.

Range("D5").Value = 1
like image 67
Scott Craner Avatar answered Jul 18 '26 13:07

Scott Craner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!