Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Script to change part of the text in a cell after a certain character

$
0
0

Long story short: how do I automate it so that the text in a cell changes to red after the symbol "Ⓡ" is detected?

I am putting together a sheet to record results for my favourite football (soccer) team which includes listing goal scorers and red carded players, but I also want to find a way to automatically change the colour of the text in a cell when there's a red card in the game.

I don't want to put them in separate cells because this is the kind of look I'd like to replicate (albeit with the ejected player's name in red as well)

BBC Results example

I've been doing it myself manually, but I'm hoping to find a way to automate the process. The solution I've come up with is to add "Ⓡ" before listing the rest of the text after listing all of the goal scorers.

I've used the script I found here (https://webapps.stackexchange.com/a/167300/363490) to figure out how to change the "Ⓡ" to red, but I can't figure out how to change anything after that.

Ignore the changes below the "Ⓡ" in the screenshot, I just put in nonsense that I'm unlikely to ever write so I can use the functionality in future if I want to.

enter image description here

I know I can use REGEXEXTRACT to find all text after "Ⓡ" in a given cell, for example I attempted to use conditional formatting with the formula: =REGEXEXTRACT(J:J,".*Ⓡ (.*)") (J being one of the columns I'm using), and that did return what I wanted in terms of the text, but I cannot figure out how to incoporate that formula into the script I've used so the colour changes to red.

Here's how it looks in the Sheet currently. The first row (10) is how I would like it to look (edited manually), while the second row (11) is how far I've got with only the red "Ⓡ" currently working using the script.

enter image description here

I hope this makes sense! (and please don't hold my love of Manchester United against me :D)


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>