Ask Your Question
0

IF + Conditional formatting

asked 2020-07-10 15:07:56 +0200

michaelbr gravatar image

updated 2020-09-26 11:53:31 +0200

Alex Kemp gravatar image

How do I accomplish this task?

Suppose I have 1 reference cell R1, and I have 2 columns, C and D, just to make it simple, let's assume it has only 3 rows, C1=<5, C2=5-10, C3>10, if my R1 is 6, then I'd like to put a mark (O for instance) in D2, with background yellow, but if my R1 is 3, then D1 should have O with yellow color. My initial thought is having an IF on D column to test the values and put an O, and then conditional formatting to change the yellow background, I'm still learning CF (Conditional Formatting), so not sure how to accomplish this. can someone please point me to the right direction? Or is there any tutorial explaining details of CF? ps: I've attached an example with 5 rows to show what I'd like to accomplish.C:\fakepath\15943082546679422.ods

edit retag flag offensive close merge delete

Comments

Why did you put your O into C7, while your description doesn't tell about what to happen if the reference is 16. From my perspective it looks a bit you want the row describing the range into which the value of your reference cell falls into having an O (in colum C if Male / in column D if Female).

Opaque gravatar imageOpaque ( 2020-07-10 15:59:51 +0200 )edit

Sorry Opaque, the description above is different from the spreadsheet, I used a short description to simplify my explanation, and I'm afraid that I made it worse.

michaelbr gravatar imagemichaelbr ( 2020-07-11 14:00:59 +0200 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2020-07-10 16:07:02 +0200

Opaque gravatar image

updated 2020-07-10 16:09:58 +0200

Hello,

See the following extension of the file I've provided with the answer to your last question: C:\fakepath\ConditionalMaleFemale+IF.ods

Now test using drop down in A2, which only handles the two cases (3 and 6) of your description. Formlual in C2: =IF(A2=3;"O";"") D2: =IF(A2=6;"O";"")

And there is an additional Conditional Formatting for Range C2:D2.

Hope that helps.

edit flag offensive delete link more

Comments

Thanks Opaque again for your help, I tried to use Formula is =C$2:D$2="O", doesn't work, why? What's the difference? Maybe Formula is only can test single cell?

michaelbr gravatar imagemichaelbr ( 2020-07-10 19:23:11 +0200 )edit

Common problem to understand how Conditional Fomatting internally works for ranges: You never need to specify the range in a formula but the formula for the upper left corner cell of a range.

Condition 1: Formula isC2="O"RangeC2:D2

The Conditional Formatting algorithm assures, that the formula is adapted for each cell of the defined range (here: C2:D2). Though you defined the rule only once (for the upper left corner cell of the range, internally the following happens:

  • Ah - have to condiitional format C2:D2, lets start with C2 (upper left corner)
  • Check the rule C2="O" and do the required formatting, if rule yields true
  • Move to D2 (next cell of the range)
  • adapt the rule to D2="O"
  • Check the adapted rule D2="O" and do the required formatting, if rule yields true
Opaque gravatar imageOpaque ( 2020-07-11 14:25:54 +0200 )edit

Thanks so much for this detailed explanation, now it's clear.

michaelbr gravatar imagemichaelbr ( 2020-07-12 14:42:13 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-10 15:07:56 +0200

Seen: 148 times

Last updated: Jul 10 '20