0

I am trying to indirectly reference another sheet within my Google sheets document in order to compare a string and color the cell accordingly if the text matches. Let's say that Sheet 1 is a list of employees with defining characteristics about that person, and Sheet 2 is another sheet where I reference that employee's name and want to format the cell based on their characteristics.

Like so:

Sheet 1:

  A    B
1 Jim  Man
2 Kate Woman

Sheet 2:

  A    B    C
4           Jim
5
6           Kate

When I reference that person in another sheet, like Sheet 2 cell C4, I want it to automatically be shaded a specific color if Jim is a man.

Then I would want to have cell C6 shaded a different color if Kate is a woman (different formatting rule, I would think, using the same structure but matching different text.)

I tried using this formula applied to cell C4:

=B1>INDIRECT("Sheet2!B2")="Man"

Should I be using ref_text to compare the indirect value to "Man"? Or should I be using ref_style and checking if the return is true or false?

I've never referenced another sheet in a conditional formatting rule before so appreciate any help in advance.

2 Answers 2

1
  • Select the data range on Sheet2 (for example, select the entire column by clicking in the "C" header cell)
  • Select Format, Conditional formatting
  • Add a rule
    • Custom formula
      • ="Man"=vlookup(C1,indirect("Sheet1!$A$1:$B$2"),2,)
      • Select the cell background colour
      • Click OK
  • Add another rule
    • Custom formula
    • ="Woman"=vlookup(C1,indirect("Sheet1!$A$1:$B$2"),2,)
      • Select the cell background colour
      • Click OK

sample2

Sign up to request clarification or add additional context in comments.

1 Comment

I'll throw in the suggestion to swap the sides of your equation to be ="Woman"=vlookup(C1,indirect("Sheet1!$A$1:$B$2"),2,) so that you can see which equation applies to which gender in the Conditional Formatting sidebar.
-1

=IFERROR(INDEX(Sheet1!B:B, MATCH(C4, Sheet1!A:A, 0)) = "Woman", FALSE)

=IFERROR(INDEX(Sheet1!B:B, MATCH(C4, Sheet1!A:A, 0)) = "Man", FALSE)

it will give you a correct data

2 Comments

Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?
Also, while you’re at it, please revisit your formatting. The StackOverflow post authoring controls give you that ability—or you can you any standard Markdown capabilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.