MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Case sensitive string


Posted by M@ on October 09, 2001 3:26 AM

I am trying to change a row colour depending upon the text string in a cell. In VBA I have this code which works well:

If .Value = "Egg" Or .Value = "egg" Then
.EntireRow.Interior.ColorIndex = 35


However, If somebody writes in the cell EGG or EGg etc. then this code will not recognize the string.

My question is can I make the statement so that the text string is case-INsensitive?

Best regards
Mat


Posted by Dank on October 09, 2001 4:26 AM

You could use Ucase like this

If UCase(.Value) = "EGG" Then
.EntireRow.Interior.ColorIndex = 35
End If

Regards,
Daniel.