=AND(ISTEXT(C2), COUNTIF($C2:Y$22, LEFT(C2,4)&"*")>1) The conditional formula above…
- User
=AND(ISTEXT(C2), COUNTIF(22, LEFT(C2,4)&"*")>1)
The conditional formula above finds all text values in the range C2:Y22 where the four letters from the left are identical.
Unfortunately, the formula does not highlight the last occurrence that matches the condition.
How can all the occurences that match the condition be highlighted.
- Assistant
To highlight all occurrences that match the condition, you can modify the formula to use conditional formatting with a custom formula.
Here are the steps to do this:
- Select the range C2:Y22.
- Go to the "Home" tab in the Ribbon.
- Click on "Conditional Formatting" and then select "New Rule".
- In the "New Formatting Rule" dialog box, select "Use a formula to determine which cells to format".
- In the "Format values where this formula is true" field, enter the following formula:
=AND(ISTEXT(C2), COUNTIF($C2:Y$22, LEFT(C2,4)&"*")>1). - Click on the "Format" button to choose the formatting style you want to apply to the matching cells. For example, you can select a fill color or font color.
- Click "OK" to close the "Format Cells" dialog box.
- Click "OK" again to close the "New Formatting Rule" dialog box.
The formatting will now be applied to all occurrences that match the condition in the selected range.
- User
Your formula does exactly the same thing. The last occurrence that matches the condition in the selected range is not highlighted
- Assistant
Apologies for the confusion. To highlight the last occurrence that matches the condition, you can use a combination of conditional formatting and a helper column to track the occurrence count. Here are the steps:
- Insert a new column (for example, column Z) next to your data range (C2:Y22).
- In cell Z2, enter the following formula to count the occurrences:
=IF(AND(ISTEXT(C2), COUNTIF($C2:Y$22, LEFT(C2,4)&"*")>1), COUNTIF($C$2:$C2, C2), ""). This formula checks if the cell in column C meets the condition and counts the occurrences up to that row. - Drag the formula in cell Z2 down to apply it to the rest of the range Z2:Z22.
- Select the range C2:Y22.
- Go to the "Home" tab in the Ribbon.
- Click on "Conditional Formatting" and then select "New Rule".
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.