Skip to content

Instantly share code, notes, and snippets.

@isann
Last active October 11, 2015 20:08
Show Gist options
  • Save isann/3912589 to your computer and use it in GitHub Desktop.
Save isann/3912589 to your computer and use it in GitHub Desktop.
google spread sheet 条件書式のような機能
function setColor() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var startRow = 2; // 開始行を指定
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
for (var i = startRow; i <= lastRow; i++ ) {
var range = sheet.getRange(i, 1, 1 ,lastColumn);
// 色を設定するための値(ステータス)を取得する。
// 行オフセット、列オフセット(一番左が0はじまりで取得する列数を指定。ここの値をステータス列の列数に変更すればOK)、
// オフセット範囲の行数、オフセット範囲の列数
var value = range.offset(0, 1, 1, 1).getValue();
if (value == "済") { // 値を設定する
range.setBackgroundColor("#A9A9A9"); // 色は適当
} else if(value == "不要") { // 値を設定する
range.setBackgroundColor("#A9A9A9"); // 色は適当
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment