Comparing three columns in Excel to find matches is easily achieved using formulas and conditional formatting. COMPARE.EDU.VN provides comprehensive guides to streamline this process. Simplify your data analysis and quickly identify matching entries across columns with Excel’s versatile features.
1. Understanding the Need to Compare Three Columns in Excel
Why is comparing three columns in Excel important? Businesses and individuals often deal with large datasets where identifying matching entries across multiple columns is crucial. This task can range from verifying data consistency to identifying duplicate records. Whether you’re managing inventory, analyzing survey responses, or ensuring data integrity, knowing how to compare three columns in Excel efficiently is a valuable skill.
1.1. Common Scenarios for Comparing Three Columns
There are several practical scenarios where comparing three columns in Excel can be incredibly useful. For example:
- Data Validation: Ensuring that data entered across different columns is consistent and accurate.
- Inventory Management: Comparing stock levels across different warehouses or tracking systems.
- Survey Analysis: Identifying respondents who provided the same answers to related questions.
- Customer Relationship Management (CRM): Matching customer data across different sources to create a unified view.
- Financial Auditing: Verifying financial records by comparing entries across different ledgers or accounts.
- HR Management: Matching employee data, such as performance reviews or training records.
These scenarios highlight the broad applicability of this technique in various professional fields.
1.2. Challenges of Manual Comparison
Manually comparing three columns in Excel, especially with large datasets, is time-consuming, error-prone, and inefficient. The human eye can easily miss discrepancies, leading to inaccurate results and potentially flawed decision-making.
- Time Consumption: Manually checking each row is tedious and takes a significant amount of time.
- Human Error: The likelihood of making mistakes increases with the volume of data.
- Lack of Scalability: Manual comparison is not feasible for large datasets, making it difficult to scale your analysis.
- Inconsistency: Different individuals may interpret data differently, leading to inconsistent results.
- Difficulty in Identifying Patterns: Manual comparison makes it hard to spot patterns or trends in the data.
Automating this process using Excel formulas and conditional formatting not only saves time but also ensures accuracy and consistency.
1.3. Benefits of Automating the Comparison Process
Automating the comparison of three columns in Excel offers numerous advantages:
- Efficiency: Quickly process large datasets with minimal effort.
- Accuracy: Reduce the risk of human error and ensure reliable results.
- Scalability: Easily handle datasets of any size without compromising accuracy.
- Consistency: Apply the same comparison criteria across the entire dataset.
- Time-Saving: Free up valuable time for more strategic tasks.
- Improved Decision-Making: Make informed decisions based on accurate and reliable data.
By leveraging Excel’s built-in functions, you can transform a tedious manual task into an efficient and automated process.
2. Methods to Compare Three Columns in Excel
Excel offers several methods to compare three columns effectively. These include using the IF and AND functions, employing conditional formatting, and utilizing more advanced functions like COUNTIF and MATCH. Each method has its strengths and is suitable for different scenarios.
2.1. Using the IF and AND Functions
The IF and AND functions are a fundamental approach to comparing three columns in Excel. This method is straightforward and easy to understand, making it ideal for beginners.
2.1.1. Basic Formula Structure
The basic formula structure involves using the AND function to check if all three columns have equal values and then using the IF function to return a specific result based on whether the condition is true or false.
The formula is structured as follows:
=IF(AND(Column1=Column2, Column2=Column3), "Match", "No Match")
Here, Column1
, Column2
, and Column3
represent the cell references of the first, second, and third columns you want to compare. The formula returns “Match” if all three columns have equal values and “No Match” otherwise.
2.1.2. Step-by-Step Guide
- Open your Excel sheet: Open the Excel sheet containing the data you want to compare.
- Select the first cell: Select the first cell in a new column where you want to display the comparison results (e.g., cell D2).
- Enter the formula: Enter the formula
=IF(AND(A2=B2, B2=C2), "Match", "No Match")
into the cell. ReplaceA2
,B2
, andC2
with the actual cell references of the columns you want to compare. - Apply the formula to the entire column: Drag the fill handle (the small square at the bottom-right of the cell) down to apply the formula to the entire column.
2.1.3. Advantages and Limitations
Advantages:
- Simple and Easy to Understand: The formula is straightforward and easy to grasp, even for Excel beginners.
- Quick Implementation: It can be quickly implemented with minimal effort.
- Direct Result: It provides a direct “Match” or “No Match” result, making it easy to interpret.
Limitations:
- Limited Flexibility: It only checks for exact matches and doesn’t offer flexibility for partial matches or tolerance.
- Not Suitable for Complex Comparisons: It may not be suitable for more complex comparisons involving multiple criteria or conditions.
- Doesn’t Handle Errors Well: If any of the cells contain errors, the formula may return an incorrect result.
Despite its limitations, the IF and AND functions provide a simple and effective way to compare three columns in Excel for exact matches.
2.2. Using Conditional Formatting
Conditional formatting is a powerful Excel feature that allows you to highlight cells based on specific criteria. When comparing three columns, conditional formatting can visually identify rows where all three columns match.
2.2.1. How to Highlight Matching Rows
To highlight matching rows using conditional formatting, follow these steps:
- Select the data range: Select the range of cells you want to compare (e.g., A2:C10).
- Open Conditional Formatting: Go to the “Home” tab on the Excel ribbon and click on “Conditional Formatting” in the “Styles” group.
- Create a New Rule: Select “New Rule” from the dropdown menu.
- Use a Formula: In the “New Formatting Rule” dialog box, select “Use a formula to determine which cells to format.”
- Enter the formula: Enter the formula
=AND($A2=$B2, $B2=$C2)
in the formula box. Note the use of absolute references ($
) to ensure the comparison is applied correctly to each row. - Format the Cells: Click on the “Format” button to choose the formatting style you want to apply to the matching rows (e.g., fill color, font style).
- Apply the Rule: Click “OK” to apply the rule and close the dialog box.
Now, all rows where the values in the three selected columns match will be highlighted according to the formatting style you chose.
2.2.2. Customizing Formatting Rules
Excel allows you to customize conditional formatting rules to suit your specific needs. You can change the formatting style, adjust the formula, or add multiple rules to highlight different types of matches.
- Changing the Formatting Style: You can change the fill color, font style, border style, or number format of the highlighted cells.
- Adjusting the Formula: You can modify the formula to include additional criteria or conditions. For example, you can add an OR condition to highlight rows where at least two columns match.
- Adding Multiple Rules: You can add multiple conditional formatting rules to highlight different types of matches with different formatting styles.
2.2.3. Advantages and Limitations
Advantages:
- Visual Identification: Conditional formatting provides a visual way to identify matching rows, making it easy to spot patterns and trends.
- Customizable: You can customize the formatting style and rules to suit your specific needs.
- Dynamic: The formatting is dynamic and automatically updates as the data changes.
Limitations:
- No Direct Output: Conditional formatting doesn’t provide a direct “Match” or “No Match” output, which may be necessary for further analysis.
- Limited to Highlighting: It is limited to highlighting cells and cannot perform other actions, such as filtering or sorting.
- Can Slow Down Performance: Applying too many conditional formatting rules can slow down Excel’s performance, especially with large datasets.
Conditional formatting is a valuable tool for visually identifying matching rows in Excel, but it may not be suitable for all types of comparisons.
2.3. Using COUNTIF Function
The COUNTIF function is another useful method for comparing three columns in Excel. This function counts the number of cells within a range that meet a given criterion, which can be used to identify matching entries across multiple columns.
2.3.1. Formula Implementation
The formula implementation involves using the COUNTIF function to count the number of times each value in the first column appears in the other two columns. If the count is equal to 2, it means the value appears in all three columns.
The formula is structured as follows:
=IF(COUNTIF(Column2:Column3, Column1)=2, "Match", "No Match")
Here, Column1
represents the cell reference of the first column you want to compare, and Column2:Column3
represents the range of cells in the second and third columns. The formula returns “Match” if the value in the first column appears in both the second and third columns and “No Match” otherwise.
2.3.2. Advantages and Limitations
Advantages:
- Versatile: The COUNTIF function is versatile and can be used for various types of comparisons, including exact matches and partial matches.
- Easy to Understand: The formula is relatively easy to understand, even for Excel beginners.
- Direct Result: It provides a direct “Match” or “No Match” result, making it easy to interpret.
Limitations:
- Limited Flexibility: It only checks if the value in the first column appears in the other two columns and doesn’t offer flexibility for more complex comparisons.
- Not Suitable for Multiple Criteria: It may not be suitable for comparisons involving multiple criteria or conditions.
- Can Be Slow with Large Datasets: The COUNTIF function can be slow with large datasets, especially when used with complex formulas.
Despite its limitations, the COUNTIF function provides a useful way to compare three columns in Excel and identify matching entries.
2.4. Using the MATCH Function
The MATCH function searches for a specified item in a range of cells and returns the relative position of that item in the range. This function can be used to compare three columns in Excel by checking if the values in the first column exist in the other two columns.
2.4.1. Syntax and Usage
The syntax of the MATCH function is as follows:
=MATCH(lookup_value, lookup_array, [match_type])
lookup_value
: The value you want to find in the lookup array.lookup_array
: The range of cells you want to search in.[match_type]
: Optional. Specifies how Excel matches the lookup value with values in the lookup array. Common values are 0 (exact match), 1 (less than), and -1 (greater than).
To use the MATCH function to compare three columns, you can combine it with the ISNUMBER function to check if the MATCH function returns a number (i.e., a match is found).
2.4.2. Combining with ISNUMBER for Logical Tests
The ISNUMBER function returns TRUE if a value is a number and FALSE otherwise. By combining the MATCH function with the ISNUMBER function, you can create a logical test to check if the values in the first column exist in the other two columns.
The formula is structured as follows:
=IF(AND(ISNUMBER(MATCH(Column1, Column2, 0)), ISNUMBER(MATCH(Column1, Column3, 0))), "Match", "No Match")
Here, Column1
represents the cell reference of the first column you want to compare, and Column2
and Column3
represent the ranges of cells in the second and third columns. The formula returns “Match” if the value in the first column appears in both the second and third columns and “No Match” otherwise.
2.4.3. Advantages and Limitations
Advantages:
- Exact Match: The MATCH function can be used to find exact matches, ensuring accuracy in the comparison.
- Flexible: It can be used with different match types to find partial matches or values within a certain range.
- Direct Result: It provides a direct “Match” or “No Match” result, making it easy to interpret.
Limitations:
- Complex Formula: The formula can be complex and difficult to understand for Excel beginners.
- Error Handling: It may not handle errors well, especially when the lookup value is not found in the lookup array.
- Performance: The MATCH function can be slow with large datasets, especially when used with complex formulas.
Despite its limitations, the MATCH function provides a powerful way to compare three columns in Excel and identify matching entries with precision.
3. Advanced Techniques and Considerations
Beyond the basic methods, there are advanced techniques and considerations that can enhance the efficiency and accuracy of comparing three columns in Excel. These include handling case sensitivity, dealing with errors, and optimizing performance with large datasets.
3.1. Handling Case Sensitivity
Excel is case-insensitive by default, meaning it treats uppercase and lowercase letters as the same. However, in some cases, you may need to perform case-sensitive comparisons.
3.1.1. Using EXACT Function
The EXACT function compares two text strings and returns TRUE if they are exactly the same, including case. You can use the EXACT function to perform case-sensitive comparisons when comparing three columns in Excel.
The formula is structured as follows:
=IF(AND(EXACT(Column1, Column2), EXACT(Column2, Column3)), "Match", "No Match")
Here, Column1
, Column2
, and Column3
represent the cell references of the first, second, and third columns you want to compare. The formula returns “Match” if all three columns have equal values, including case, and “No Match” otherwise.
3.1.2. Advantages and Limitations
Advantages:
- Case-Sensitive Comparison: The EXACT function allows you to perform case-sensitive comparisons, ensuring accuracy when case matters.
- Simple Implementation: The formula is relatively easy to implement with minimal effort.
- Direct Result: It provides a direct “Match” or “No Match” result, making it easy to interpret.
Limitations:
- Limited Flexibility: It only checks for exact matches, including case, and doesn’t offer flexibility for partial matches or tolerance.
- Not Suitable for Complex Comparisons: It may not be suitable for more complex comparisons involving multiple criteria or conditions.
- Can Be Slow with Large Datasets: The EXACT function can be slow with large datasets, especially when used with complex formulas.
The EXACT function provides a simple and effective way to perform case-sensitive comparisons when comparing three columns in Excel.
3.2. Dealing with Errors (e.g., #N/A)
Errors such as #N/A can occur in Excel when a formula cannot find a matching value or encounters an invalid operation. When comparing three columns, it’s important to handle these errors to avoid incorrect results.
3.2.1. Using IFERROR Function
The IFERROR function allows you to handle errors by returning a specified value if a formula evaluates to an error. You can use the IFERROR function to handle errors when comparing three columns in Excel.
The formula is structured as follows:
=IFERROR(IF(AND(Column1=Column2, Column2=Column3), "Match"), "Error")
Here, Column1
, Column2
, and Column3
represent the cell references of the first, second, and third columns you want to compare. The formula returns “Match” if all three columns have equal values and “Error” if any of the cells contain an error.
3.2.2. Advantages and Limitations
Advantages:
- Error Handling: The IFERROR function allows you to handle errors and avoid incorrect results.
- Simple Implementation: The formula is relatively easy to implement with minimal effort.
- Customizable: You can customize the error message to suit your specific needs.
Limitations:
- Doesn’t Identify the Source of the Error: The IFERROR function only indicates that an error has occurred but doesn’t identify the source of the error.
- Can Hide Underlying Issues: Hiding errors can prevent you from identifying and fixing underlying issues in your data.
- May Not Be Suitable for Complex Comparisons: It may not be suitable for more complex comparisons involving multiple criteria or conditions.
The IFERROR function provides a useful way to handle errors when comparing three columns in Excel, but it’s important to use it judiciously and address the underlying issues in your data.
3.3. Performance Optimization for Large Datasets
When working with large datasets, performance optimization is crucial to ensure that Excel formulas and conditional formatting rules don’t slow down your computer.
3.3.1. Using Array Formulas
Array formulas can perform calculations on multiple values at once, which can be more efficient than using regular formulas with large datasets.
To use an array formula to compare three columns, follow these steps:
- Select the Output Range: Select the range of cells where you want to display the comparison results.
- Enter the Formula: Enter the array formula
=IF(A2:A10=B2:B10, IF(B2:B10=C2:C10, "Match", "No Match"), "No Match")
into the formula bar. - Enter as Array Formula: Press
Ctrl + Shift + Enter
to enter the formula as an array formula. Excel will automatically add curly braces{}
around the formula.
3.3.2. Reducing Volatile Functions
Volatile functions are functions that recalculate every time Excel recalculates, even if their inputs haven’t changed. Using too many volatile functions can slow down Excel’s performance.
Examples of volatile functions include NOW()
, TODAY()
, and RAND()
. Avoid using these functions in your formulas if possible, or replace them with non-volatile alternatives.
3.3.3. Using Helper Columns
Helper columns are columns that contain intermediate calculations that are used in other formulas. Using helper columns can simplify complex formulas and improve Excel’s performance.
For example, you can create a helper column that concatenates the values in the three columns you want to compare and then use a simple formula to check if the concatenated values are equal.
3.3.4. Avoiding Excessive Conditional Formatting
Applying too many conditional formatting rules can slow down Excel’s performance, especially with large datasets. To avoid this, try to consolidate your conditional formatting rules into as few rules as possible.
You can also use the “Stop If True” option in the “Edit Formatting Rule” dialog box to prevent Excel from evaluating subsequent rules once a match is found.
By implementing these performance optimization techniques, you can ensure that Excel formulas and conditional formatting rules run efficiently, even with large datasets.
4. Practical Examples and Use Cases
To further illustrate the practical applications of comparing three columns in Excel, let’s explore some real-world examples and use cases.
4.1. Data Validation in Spreadsheets
Data validation is the process of ensuring that data entered into a spreadsheet is accurate, consistent, and complete. Comparing three columns can be used to validate data by checking if the values in the columns match.
4.1.1. Ensuring Consistency in Data Entry
In many organizations, data is entered by multiple individuals, which can lead to inconsistencies and errors. Comparing three columns can help identify these inconsistencies and ensure that data is entered consistently.
For example, suppose you have a spreadsheet that tracks customer information, and you want to ensure that the customer’s name, address, and phone number are entered correctly. You can compare the values in the corresponding columns to identify any discrepancies.
4.1.2. Identifying Duplicate Records
Duplicate records can occur in spreadsheets when the same data is entered multiple times. Comparing three columns can help identify duplicate records by checking if the values in the columns are the same.
For example, suppose you have a spreadsheet that tracks sales leads, and you want to ensure that each lead is entered only once. You can compare the values in the corresponding columns to identify any duplicate records.
4.2. Inventory Management
Inventory management is the process of tracking and controlling the flow of goods from suppliers to customers. Comparing three columns can be used to manage inventory by checking if the stock levels in different warehouses or tracking systems match.
4.2.1. Comparing Stock Levels Across Warehouses
In many organizations, inventory is stored in multiple warehouses, which can make it difficult to track stock levels accurately. Comparing three columns can help compare stock levels across warehouses and identify any discrepancies.
For example, suppose you have a spreadsheet that tracks inventory levels in three different warehouses, and you want to ensure that the stock levels are consistent across all warehouses. You can compare the values in the corresponding columns to identify any discrepancies.
4.2.2. Tracking Inventory Movements
Tracking inventory movements is essential for effective inventory management. Comparing three columns can help track inventory movements by checking if the quantity of goods received matches the quantity of goods shipped.
For example, suppose you have a spreadsheet that tracks inventory movements, and you want to ensure that the quantity of goods received matches the quantity of goods shipped. You can compare the values in the corresponding columns to identify any discrepancies.
4.3. Survey Analysis
Survey analysis is the process of analyzing data collected from surveys to gain insights and make informed decisions. Comparing three columns can be used to analyze survey data by identifying respondents who provided the same answers to related questions.
4.3.1. Identifying Consistent Responses
In surveys, respondents are often asked multiple questions on the same topic. Comparing three columns can help identify respondents who provided consistent responses to these questions.
For example, suppose you have a survey that asks respondents about their satisfaction with a product, and you want to identify respondents who provided consistent responses to the satisfaction questions. You can compare the values in the corresponding columns to identify any discrepancies.
4.3.2. Identifying Patterns in Responses
Identifying patterns in responses can provide valuable insights into survey data. Comparing three columns can help identify patterns in responses by checking if respondents provided the same answers to related questions.
For example, suppose you have a survey that asks respondents about their preferences for different product features, and you want to identify patterns in responses. You can compare the values in the corresponding columns to identify any patterns.
5. Common Mistakes to Avoid
When comparing three columns in Excel, it’s important to avoid common mistakes that can lead to inaccurate results.
5.1. Incorrect Cell References
One of the most common mistakes is using incorrect cell references in formulas. This can lead to incorrect comparisons and inaccurate results.
To avoid this mistake, double-check your cell references before entering the formula, and use absolute references ($
) when necessary.
5.2. Forgetting to Apply Formulas to All Rows
Another common mistake is forgetting to apply formulas to all rows in the dataset. This can lead to incomplete comparisons and inaccurate results.
To avoid this mistake, make sure to drag the fill handle down to apply the formula to all rows in the dataset.
5.3. Ignoring Data Types
Ignoring data types can also lead to inaccurate comparisons. For example, if you’re comparing numbers and text, Excel may not be able to perform the comparison correctly.
To avoid this mistake, make sure that the data types in the columns you’re comparing are consistent.
5.4. Not Handling Errors
Not handling errors can also lead to inaccurate results. Errors such as #N/A can occur in Excel when a formula cannot find a matching value or encounters an invalid operation.
To avoid this mistake, use the IFERROR function to handle errors and avoid incorrect results.
By avoiding these common mistakes, you can ensure that your comparisons are accurate and reliable.
6. Conclusion: Streamlining Data Comparison with Excel
Comparing three columns in Excel is a valuable skill for anyone who works with data. By using the methods and techniques outlined in this article, you can streamline your data comparison process and improve the accuracy and efficiency of your analysis.
Whether you’re validating data, managing inventory, or analyzing survey responses, Excel provides a range of tools and functions to help you compare three columns effectively.
Remember to avoid common mistakes, handle errors, and optimize performance with large datasets. With practice and experience, you’ll become proficient at comparing three columns in Excel and extracting valuable insights from your data.
6.1. Recap of Key Methods
Here’s a quick recap of the key methods for comparing three columns in Excel:
- IF and AND Functions: A simple and straightforward method for comparing three columns for exact matches.
- Conditional Formatting: A powerful feature for visually identifying matching rows.
- COUNTIF Function: A versatile function for counting the number of times each value appears in the other columns.
- MATCH Function: A precise function for finding exact matches in a range of cells.
6.2. Encouragement to Explore Further
Excel is a powerful tool with a wide range of features and functions. We encourage you to explore further and discover new ways to use Excel to streamline your data analysis tasks.
Experiment with different formulas, conditional formatting rules, and advanced techniques to find the methods that work best for you.
6.3. Call to Action to Visit COMPARE.EDU.VN
For more in-depth tutorials, practical examples, and expert advice on comparing data and making informed decisions, visit COMPARE.EDU.VN.
At COMPARE.EDU.VN, you’ll find a wealth of resources to help you master Excel and other data analysis tools. Our comprehensive guides, step-by-step instructions, and real-world examples will empower you to streamline your data comparison process and make more informed decisions.
Whether you’re a beginner or an experienced Excel user, COMPARE.EDU.VN has something to offer you. Visit our website today and start exploring the world of data analysis!
Address: 333 Comparison Plaza, Choice City, CA 90210, United States
Whatsapp: +1 (626) 555-9090
Website: COMPARE.EDU.VN
7. Frequently Asked Questions (FAQ)
7.1. How do I compare three columns in Excel for exact matches?
To compare three columns in Excel for exact matches, you can use the IF and AND functions. The formula is =IF(AND(A2=B2, B2=C2), "Match", "No Match")
. This formula checks if the values in cells A2, B2, and C2 are equal. If they are, the formula returns “Match”; otherwise, it returns “No Match”.
7.2. Can I highlight matching rows in Excel based on three columns?
Yes, you can highlight matching rows in Excel based on three columns using conditional formatting. Select the data range, go to “Conditional Formatting,” create a “New Rule,” use a formula, and enter =AND($A2=$B2, $B2=$C2)
. Then, choose a formatting style to highlight the matching rows.
7.3. How can I perform a case-sensitive comparison of three columns in Excel?
To perform a case-sensitive comparison of three columns in Excel, use the EXACT function. The formula is =IF(AND(EXACT(A2, B2), EXACT(B2, C2)), "Match", "No Match")
. The EXACT function compares two text strings and returns TRUE if they are exactly the same, including case.
7.4. What is the best way to handle errors when comparing three columns in Excel?
To handle errors when comparing three columns in Excel, use the IFERROR function. The formula is =IFERROR(IF(AND(A2=B2, B2=C2), "Match"), "Error")
. The IFERROR function allows you to return a specified value if a formula evaluates to an error, preventing incorrect results.
7.5. How do I optimize performance when comparing three columns in Excel with large datasets?
To optimize performance when comparing three columns in Excel with large datasets, consider using array formulas, reducing volatile functions, using helper columns, and avoiding excessive conditional formatting. These techniques can improve Excel’s performance and ensure that your formulas run efficiently.
7.6. Can I use the COUNTIF function to compare three columns in Excel?
Yes, you can use the COUNTIF function to compare three columns in Excel. The formula is =IF(COUNTIF(B2:C2, A2)=2, "Match", "No Match")
. This formula counts the number of times the value in cell A2 appears in the range B2:C2. If the count is 2, it means the value appears in all three columns.
7.7. How does the MATCH function help in comparing three columns in Excel?
The MATCH function searches for a specified item in a range of cells and returns the relative position of that item in the range. By combining the MATCH function with the ISNUMBER function, you can create a logical test to check if the values in the first column exist in the other two columns.
7.8. What are some common mistakes to avoid when comparing three columns in Excel?
Some common mistakes to avoid when comparing three columns in Excel include using incorrect cell references, forgetting to apply formulas to all rows, ignoring data types, and not handling errors. Avoiding these mistakes will ensure that your comparisons are accurate and reliable.
7.9. How can COMPARE.EDU.VN help me with comparing data in Excel?
COMPARE.EDU.VN provides in-depth tutorials, practical examples, and expert advice on comparing data and making informed decisions. Our comprehensive guides, step-by-step instructions, and real-world examples will empower you to streamline your data comparison process and make more informed decisions.
7.10. Where can I find more resources and support for comparing data in Excel?
You can find more resources and support for comparing data in Excel on compare.edu.vn. Visit our website to explore our comprehensive guides, tutorials, and expert advice.
The Excel screenshot demonstrates applying an “equal” formula to compare three columns.
The user interface of Excel showcases the “Highlight Cell Rules” function for conditional formatting.