Conditional Formatting

Venners

New Member
Joined
Jul 12, 2022
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
Is there a way to highlight a cell that precedes another cell if other certain cells are matching? So in the dataset below I need to highlight all instances where a cross immediately precedes a shot but it needs to be the same id number to signal the different games and it needs to be the same team having the cross and shot.

Example.xlsx
ABCDE
1idteamevent_typecurrentHalfclockTime
23023090Team AChancesecondHalf80:32:00
33023090Team ACrosssecondHalf80:32:00
43023090Team Bevent_AsecondHalf80:16:00
53023090Team APasssecondHalf80:13:00
63023088Team Cevent_AsecondHalf67:51:00
73023088Team DCrosssecondHalf67:51:00
83023088Team CPasssecondHalf67:50:00
93023088Team Devent_AsecondHalf67:24:00
103023088Team CCrosssecondHalf67:24:00
113023088Team Cevent_AsecondHalf67:02:00
123023088Team DCrosssecondHalf67:02:00
133023088Team Cevent_AsecondHalf66:41:00
143023088Team Devent_AsecondHalf65:58:00
153023088Team CChancesecondHalf65:58:00
163023088Team CCrosssecondHalf65:43:00
173023088Team DChancesecondHalf65:43:00
183023088Team Cevent_AsecondHalf65:39:00
193023088Team DPasssecondHalf65:39:00
203023088Team Devent_AsecondHalf65:05:00
213023088Team Cevent_AsecondHalf64:53:00
223023088Team DCrosssecondHalf64:53:00
233022889Team Eevent_CsecondHalf95:21:00
243022889Team Devent_BsecondHalf95:06:00
253022889Team Eevent_AsecondHalf94:51:00
263022889Team Devent_AsecondHalf94:49:00
273022889Team EChancesecondHalf94:49:00
283022889Team ECrosssecondHalf94:37:00
293022889Team DCrosssecondHalf94:37:00
303022889Team Devent_AsecondHalf94:31:00
313022889Team ECrosssecondHalf94:31:00
323022889Team Eevent_AsecondHalf94:19:00
333022889Team Devent_AsecondHalf94:16:00
343022889Team Devent_AsecondHalf94:13:00
Sheet1
 
Can you try this:-

=IF(AND(A1=A2,B1=B2,C1="chance",C2="cross"),"true","false")

I am a beginner and appreciate if @Venners or @Joe4 could comment on this.

Thanks in advance.
It does close to the exact same thing my code does, but is overkill, and does have one issue.

Functions like AND and OR are boolean functions, meaning that they return TRUE or FALSE based on if the conditions are met.
Since they already return TRUE or FALSE, there is no need to wrap them in an IF function.

Secondly, you would not want to wrap the words "true" and "false" in quotes, as those would then be text values, and not boolean values.

So this would be valid:
Excel Formula:
=IF(AND(A1=A2,B1=B2,C1="chance",C2="cross"),TRUE,FALSE)
but can just be simplified to this:
Excel Formula:
=AND(A1=A2,B1=B2,C1="chance",C2="cross")
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top