HomeGoogle DocsSpreadsheetHow to Highlight Intersections in Google Sheets

How to Highlight Intersections in Google Sheets

Do you want to search a row and column for specific values and highlight their intersections in Google Sheets? This is a common task when working with two-way lookup tables, and you can achieve it using a simple conditional formatting formula.

Use the following formula to highlight the intersection in Google Sheets:

=ADDRESS(ROW(), COLUMN())=CELL("address", XLOOKUP(searchKey_v, first_col, XLOOKUP(searchKey_h, first_row, table)))
  • searchKey_v → the value to look up in the first column (row lookup)
  • searchKey_h → the value to look up in the first row (column lookup)
  • first_col → the range of the first column in your table
  • first_row → the range of the first row in your table
  • table → the full table range

⚠️ When using cell or range references, make sure they are absolute references (with $) to avoid errors in conditional formatting.

Understanding Intersection Values in a Two-Way Lookup

Before highlighting intersections, it’s essential to understand what an intersection value is.

Imagine you have the following table in the range B2:E6:

Sample Google Sheets table showing names and meal preferences for highlighting intersection values

If you want to highlight Susan’s lunch, you’ll need to:

  1. Look up “Susan” in the first column.
  2. Look up “Lunch” in the first row.

The value at the intersection is “Pasta”, which we want to highlight.

Step-by-Step: Highlight Intersections in Google Sheets

Follow these steps to highlight the intersection value:

  1. Enter the search keys:
    • G2Susan
    • G3Lunch
  2. Select the table range: B2:E6.
  3. Go to Format → Conditional Formatting.
  4. In the sidebar under Single Color, select Custom formula is.
  5. Enter the following formula:
=ADDRESS(ROW(), COLUMN())=CELL("address", XLOOKUP($G$2, $B$2:$B$6, XLOOKUP($G$3, $B$2:$E$2, $B$2:$E$6)))
  1. Choose a formatting style (e.g., fill color, text color).
  2. Click Done.

✅ Now, the cell containing Susan’s lunch preference (“Pasta”) will be highlighted automatically.

Adapting the Formula for a Different Table

To adjust this formula for another range:

  • Replace $G$2 with the cell containing your row lookup value.
  • Replace $G$3 with the cell containing your column lookup value.
  • Update the ranges:
    • $B$2:$B$6 → first column of the table
    • $B$2:$E$2 → first row of the table
    • $B$2:$E$6 → full table range

Keep absolute references ($) to ensure conditional formatting works correctly.

How the Formula Works

The formula uses nested XLOOKUP:

XLOOKUP($G$2, $B$2:$B$6, XLOOKUP($G$3, $B$2:$E$2, $B$2:$E$6))
  • Inner XLOOKUP: Finds the column for the selected header (Breakfast, Lunch, Dinner).
  • Outer XLOOKUP: Finds the row for the selected name (Susan).
  • CELL(“address”, …): Returns the actual cell address of the intersection.
  • ADDRESS(ROW(), COLUMN()): Checks if the current cell matches the intersection.

When matched, the conditional formatting highlights the cell.

Conclusion

You can use this approach to highlight two-way lookup results dynamically in Google Sheets.

This technique is part of the hub post: The Ultimate Guide to Conditional Formatting in Google Sheets, which contains a comprehensive collection of tips and examples to visually analyze your data.

Resources

Prashanth K V
Prashanth K V
Your Trusted Google Sheets and Excel Expert Prashanth K V is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

How to Build a Road Trip Fuel Cost Splitter Formula in Google Sheets

Need a fair formula to split fuel costs among travelers on a long road...

Road Trip Fuel Cost Splitter in Google Sheets (Free Template)

When you go on a long road trip with friends, splitting fuel expenses fairly...

Savings Tracker Template in Google Sheets (Free Download)

Managing multiple savings goals can become difficult without a proper system to track your...

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.