実現したいこと
GoogleスプレッドシートでGASを利用し、複数の単語をリスト(配列)で持っていて、1つのセル内に該当する単語があれば複数個文字を赤くするようにしたい。
分かっていること・試したこと
調べたところ newRichTextValue() を使うことで、セル内の一部分に色をつけられることは分かりました。
スプレッドシートのマクロ機能でやりたい作業を記録させてみたところ、
function myFunction() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A1').activate(); spreadsheet.getCurrentCell().setRichTextValue( SpreadsheetApp.newRichTextValue().setText('あああああああああああああああああ') .setTextStyle(1, 5, SpreadsheetApp.newTextStyle().setForegroundColor('#ff0000').build()) .setTextStyle(11, 14, SpreadsheetApp.newTextStyle().setForegroundColor('#ff0000').build()) .build() ); };
このようなスクリプトが生成されたので、下記部分を配列に対して繰り返し処理が出来れば実現出来るかもというところまでは分かりました。
.setTextStyle(1, 5, SpreadsheetApp.newTextStyle().setForegroundColor('#ff0000').build()) .setTextStyle(11, 14, SpreadsheetApp.newTextStyle().setForegroundColor('#ff0000').build())
が、どのような書き方をすれば良いのかまったく分かりません。お力添えをお願いします。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/26 02:33
2019/02/26 05:44 編集
2019/02/27 04:00 編集
2019/02/27 04:10