In this article, we will learn How to Color cell Based on Text Criteria in Excel.
Why do we use conditional formatting to highlight cells in Excel ?
Conditional Formatting is used to highlight the data on the basis of some criteria. It would be difficult to see various trends just for examining your Excel worksheet. Conditional Formatting provides a way to visualize data and make worksheets easier to understand. It allows you to apply the formatting basis on the cell values such as colours, icons and data bars.
Excel Conditional formatting gives you inbuilt formulation like Highlight cells rules or top/bottom rules. These will help you achieve formulation using simple steps.
Choose the New rule to create a customized formula for highlighting cells. For example Highlight sales values where sales values are in between 150 to 1000. For this we use Conditional formatting. Try the formula in adjacent cells before applying in the conditional formatting formula box.
Formula box in Conditional formatting
After selecting the New rule in conditional formatting. Select the Use a formula to determine which cells to format -> it will open the formula box as shown in the image above. Use the formula in it and select the type of formatting to choose using Format option (like Yellow background as shown in the image).
How to solve the problem?
For this we will be using the Conditional formatting obviously. And we can use any of the two functions SEARCH function or FIND function. The difference is SEARCH function, is case insensitive which means it will match any of substrings "ABC", "Abc", "aBc", "ABc", if matched with "abc". FIND function is case sensitive which matches only substring "abc", if matched with "abc". Below shown is the generic formula to solve this problem.
SEARCH Formula Syntax:
=SEARCH(sp_val, cell)=1 |
FIND Formula Syntax:
=FIND(sp_val, cell)=1 |
sp_val : specific or particular value to match with.
cell : cell to check
Example :
All of these might be confusing to understand. Let's understand it better via running the formula on some values. Here we have some university exam codes. We need to highlight the mathematics exam codes. Mathematics Exam code begins with "MA".
What we need here is to check each cell which starts with "MA".
Go to Home -> Conditional formatting -> New Rule
A dialog box appears in front select Use a formula to determine which cells to format -> input the below formula under the Format values where this formula is True:
Use the formula:
=SEARCH($E$5,B2)=1 |
Explanation:
The background color gets Green ( highlight formatting) as you click Ok as shown above. Now copy the formula to the rest of cells using the Ctrl + D or dragging down form right bottom of B2 cell.
As you can see all the mathematics exam codes are highlighted. You can input specific value substring, with quotes(") in the formula along with an example solved using the FIND function as shown below.
FIND function is case sensitive function :
FIND function returns the position of the occurrence of the find_text value in the cell value. The difference occurs if the value you are trying to match must be case sensitive. See the below formula and snapshot to understand How to highlight cells that begin with specific value in Excel.
Use the formula :
=FIND("MA",B2)=1 |
B2 : within_text
"MA" : find_text substring
As you can see the lowercase exam code "ma-58" doesn't match the substring "MA" as we used the FIND function here. So, it's preferable to use the SEARCH function with conditional formatting. Conditional Formatting provides a way to visualize data and make worksheets easier to understand. You can perform various tasks using the different features of conditional formatting in Excel.
Here are all the observational notes regarding using the formula.
Notes:
Hope this article about How to Color cell Based on Text Criteria in Excel is explanatory. Find more articles on calculating values and related Excel formulas here. If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write to us at info@exceltip.com.
Related Articles :
Replace text from end of a string starting from variable position: To replace text from the end of the string, we use the REPLACE function. The REPLACE function uses the position of text in the string to replace.
How to Check if a cell contains one of many texts in Excel: To find check if a string contains any of multiple text, we use this formula. We use the SUM function to sum up all the matches and then perform a logic to check if the string contains any of the multiple strings.
Count Cells that contain specific text: A simple COUNTIF function will do the magic. To count the number of multiple cells that contain a given string we use the wildcard operator with the COUNTIF function.
Excel REPLACE vs SUBSTITUTE function: The REPLACE and SUBSTITUTE functions are the most misunderstood functions. To find and replace a given text we use the SUBSTITUTE function. Where REPLACE is used to replace a number of characters in string…
Popular Articles :
How to use the IF Function in Excel : The IF statement in Excel checks the condition and returns a specific value if the condition is TRUE or returns another specific value if FALSE.
How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
How to use the SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.
How to use the COUNTIF Function in Excel : Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.