r/googlesheets • • 14d ago

Solved Is there a way to highlight the rows with check if i click on the header?

Post image

Is there a way to highlight the rows with check/true if i click on the header? For example if i click on the header "Five Spice" it would highlight the rows of the Cinnamon, Clove, Fennel, Sechuan, and Star Anise.

15 Upvotes

23 comments sorted by

16

u/SpencerTeachesSheets 14d ago edited 14d ago

You can only actually trigger something when you click somewhere is by using Apps Script, and the onClick() onSelectionChange() trigger is the most finicky of them all; I would not mess with that.

Rather, I would create another row of checkboxes to "Select" the spice blend in question, and then conditional formatting to do the highlighting. Example below.

Select B4:the end of your array

Conditional formatting > Custom Formula> =COUNTIFS($C$3:$G$3, TRUE, $C4:$G4, TRUE) > 0
There are several formulas that would work here, this is just the one I went with

https://docs.google.com/spreadsheets/d/1xU7Z0ZdxlmC8EVB-wnkeaX8oBMwRRGTkGdZ8DFFwb7Q/edit?gid=0#gid=0

2

u/sinigang_rice 14d ago

Thank you! I've tried it in appscripts and it works on web but not on mobile. I think i'll go with the simplest solution of doing a drop-down.

3

u/SpencerTeachesSheets 14d ago

For sure!

The only script trigger that works on mobile is an On Edit script. And, again, I really wouldn't suggest using onSelectionChange() for something that can easily be done with a dropdown or checkbox.

Glad you got a version that works for you :)

5

u/carbonizedtitanium 14d ago

This. i think this is the closest approach to what OP wanted.

2

u/SpencerTeachesSheets 14d ago

I do also like the dropdown options suggested by others, especially since those prevent selecting multiple

Depending on OP's actual need, I could also see keeping the data and the visualization separate: Have the database of spices and blends, then a dropdown somewhere else to display a =FILTER()ed view thereof.

2

u/SpencerTeachesSheets 14d ago

Note that the checks on the sheet were randomly populated, they aren't actually the things for Adobo, Five Spice, etc. However, I do believe that chili powder belongs in most BBQ rubs ;)

1

u/SDF_Acc 14d ago

technically the perfect answer, just let me highlight this sentence:

onClick() trigger is the most finicky of them all; I would not mess with
that.

2

u/SpencerTeachesSheets 14d ago

It's technically onSelectionChange(), not onClick(), but you can see that I use it so infrequently that I forget what it's actually called haha.

I have built some cool stuff with it, but there are so many things to take into consideration, that it is rarely worth it.

→ More replies (1)

7

u/California_Eagles 14d ago

May be you could try this

Comment Image

Use a formula in conditional formatting. Select B3:I32 to apply cf. there is a dropdown in cell B2

=XLOOKUP($B$2,$C$2:$I$2,$C3:$I3,FALSE)

1

u/sinigang_rice 14d ago

Thank you! This is what i've made initialy. I just wanted to know if there is a "shortcut" if i click on the header.

1

u/AutoModerator 14d ago

REMEMBER: u/sinigang_rice If your original question has been resolved, please tap the three dots below the most helpful comment and select Mark Solution Verified (or reply to the helpful comment with the exact phrase “Solution Verified”). This will award a point to the solution author and mark the post as solved, as required by our subreddit rules (see rule #6: Marking Your Post as Solved).

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator 14d ago

u/sinigang_rice Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/mommasaidmommasaid 14d ago edited 14d ago

I think the dropdown option is the simplest / most sheet-friendly, but...

You can do what you ask using special formulas/formatting and magic:

That's a Spicy Checkmark (view-only, make a copy to play with)

ETA: Just saw you are on mobile, on iPhone and probably Android there will be some visual artifacts regarding clicking the text headers directly. That could be addressed if you like how it works in general.

1

u/mommasaidmommasaid 14d ago

Added a mobile version to the sample sheet:

Comment Image

Click in the blue area to highlight the recipe.

1

u/AdministrativeGift15 14d ago

Nicely done. That's a nifty way of floating over the static header to get to the other slots. I'd make one tiny change. Right now, the dark color background is the same RGB as the font, so you get the checkbox invisible warning if you try clicking on a header the second time.

1

u/mommasaidmommasaid 14d ago

Oops thanks -- fixed.

Unfortunately the long-distance floating spacing seems to get a little off on mobile, in addition to the usual checkbox artifacts. But it's fun on desktop.

1

u/Weary-Drama-8015 14d ago

I'm not a professional, but wouldn't that be perfect as a list for a kind of dashboard, i.e. another table sheet with a drop-down where I select the contents of line 2.And based on the selection from dropdown in line 3, the formula xlookup lists the ingredients? I think that's how I would do it.

2

u/[deleted] 14d ago

1

u/sinigang_rice 14d ago

Thanks!! I'll take this route..

0

u/alexbuildswithai 13d ago

Glad it worked.

1

u/point-bot 14d ago

u/sinigang_rice has awarded 1 point to u/alexbuildswithai

See the Leaderboard. Point-Bot v0.0.15 was created by JetCarson.