{"id":22939,"date":"2025-06-14T22:38:37","date_gmt":"2025-06-14T13:38:37","guid":{"rendered":"https:\/\/cg-method.com\/google\/?p=22939"},"modified":"2025-06-14T22:38:37","modified_gmt":"2025-06-14T13:38:37","slug":"spreadsheet-group-coloring-gas","status":"publish","type":"post","link":"https:\/\/cg-method.com\/google\/spreadsheet-group-coloring-gas\/","title":{"rendered":"Google\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u2502\u9023\u7d9a\u30c7\u30fc\u30bf\u3092\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u8272\u3067\u5857\u308a\u5206\u3051\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<p>Google \u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u300c\u540c\u3058\u5024\u304c\u9023\u7d9a\u3057\u3066\u3044\u308b\u884c\u300d\u3092\u8996\u899a\u7684\u306b\u308f\u304b\u308a\u3084\u3059\u304f\u3057\u305f\u3044\u3053\u3068\u3063\u3066\u3042\u308a\u307e\u305b\u3093\u304b\uff1f<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b A\u5217\u306b\u30b0\u30eb\u30fc\u30d7\u304c\u4e26\u3093\u3067\u3044\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u300c<strong>\u540c\u3058\u5024\u304c\u9023\u7d9a\u3057\u3066\u3044\u308b\u884c<\/strong>\u300d\u3092 <strong>\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u6de1\u3044\u8272\u3067\u5857\u308a\u5206\u3051\u308b<\/strong> \u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u304c\u4e00\u76ee\u3067\u898b\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"454\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58.png\" alt=\"\" class=\"wp-image-22941\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58.png 263w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58-174x300.png 174w\" sizes=\"auto, (max-width: 263px) 100vw, 263px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u6761\u4ef6\u4ed8\u304d\u66f8\u5f0f\u3067\u306f\u96e3\u3057\u3044\uff1f \u2192 GAS\u3067\u89e3\u6c7a\uff01<\/h2>\n\n\n\n<p>\u6761\u4ef6\u4ed8\u304d\u66f8\u5f0f\u3067\u306f\u3001\u300c\u9023\u7d9a\u3057\u3066\u3044\u308b\u540c\u3058\u5024\u3054\u3068\u306b\u8272\u3092\u5206\u3051\u308b\u300d\u3068\u3044\u3046\u51e6\u7406\u306f\u96e3\u3057\u3044\u3067\u3059\u304c\u3001<strong>Google Apps Script\uff08GAS\uff09<\/strong> \u3092\u4f7f\u3048\u3070\u4e00\u767a\u3067\u81ea\u52d5\u5316\u3067\u304d\u307e\u3059\uff01<\/p>\n\n\n\n<p>\u3053\u3053\u306f\u3042\u3048\u3066\u6761\u4ef6\u5f0f\u66f8\u5f0f\u3092\u3064\u304b\u308f\u305a\u3001\u4ed5\u5206\u3051\u305f\u3044\u6642\u306bGAS\u3067\u8272\u4ed8\u3051\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u88c5\u30b3\u30fc\u30c9\uff08GAS\uff09<\/h2>\n\n\n\n<p>\u62e1\u5f35\u6a5f\u80fd > APP Script\u304b\u3089\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u5165\u308c\u3066\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u5217\u306f\u81ea\u5206\u3067\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list is-style-num_circle\">\n<li>Google \u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3092\u958b\u304f<\/li>\n\n\n\n<li>\u30e1\u30cb\u30e5\u30fc\u300c\u62e1\u5f35\u6a5f\u80fd\u300d\u2192\u300cApps Script\u300d\u3092\u9078\u629e<\/li>\n\n\n\n<li>\u4e0a\u8a18\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u4fdd\u5b58<\/li>\n\n\n\n<li>\u300c\u25b6 \u5b9f\u884c\u300d\u30dc\u30bf\u30f3\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c<\/li>\n<\/ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>function colorGroupingsInColumnA() {\n  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();\n  const range = sheet.getRange(&quot;A1:A&quot; + sheet.getLastRow()); \/\/\u2605\u5217\u306f\u81ea\u5206\u3067\u6307\u5b9a\u3059\u308b\n  const values = range.getValues();\n\n  const colors = [\n    &quot;#f0f8ff&quot;, \/\/ \u6de1\u3044\u9752\n    &quot;#f5f5dc&quot;, \/\/ \u6de1\u3044\u30d9\u30fc\u30b8\u30e5\n    &quot;#f0fff0&quot;, \/\/ \u6de1\u3044\u7dd1\n    &quot;#fffaf0&quot;, \/\/ \u6de1\u3044\u30aa\u30ec\u30f3\u30b8\n    &quot;#f5f5f5&quot;, \/\/ \u30b0\u30ec\u30fc\u7cfb\n    &quot;#ffffe0&quot;, \/\/ \u6de1\u3044\u9ec4\u8272\n    &quot;#e6e6fa&quot;  \/\/ \u30e9\u30d9\u30f3\u30c0\u30fc\n  ];\n\n  let colorIndex = 0;\n  let startRow = 1;\n\n  for (let i = 1; i &lt; values.length; i++) {\n    if (values[i][0] !== values[i - 1][0]) {\n      const numRows = i - startRow + 1;\n      const groupRange = sheet.getRange(startRow, 1, numRows);\n      groupRange.setBackground(colors[colorIndex % colors.length]);\n      startRow = i + 1;\n      colorIndex++;\n    }\n  }\n\n  \/\/ \u6700\u5f8c\u306e\u30b0\u30eb\u30fc\u30d7\u3082\u8272\u4ed8\u3051\n  const lastGroupRange = sheet.getRange(startRow, 1, values.length - startRow + 1);\n  lastGroupRange.setBackground(colors[colorIndex % colors.length]);\n}\n<\/code><\/pre><\/div>\n\n\n\n<p>\u6700\u5f8c\u306b\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"454\" src=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58.png\" alt=\"\" class=\"wp-image-22941\" srcset=\"https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58.png 263w, https:\/\/cg-method.com\/google\/wp-content\/uploads\/2025\/06\/2025-06-14_22h34_58-174x300.png 174w\" sizes=\"auto, (max-width: 263px) 100vw, 263px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3053\u306eGAS\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u3048\u3070\u3001<strong>\u9023\u7d9a\u3057\u305f\u540c\u3058\u5024\u306e\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u4ea4\u4e92\u306e\u6de1\u3044\u8272\u3092\u4ed8\u3051\u308b<\/strong>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5927\u91cf\u30c7\u30fc\u30bf\u3067\u3082\u4e00\u76ee\u3067\u30b0\u30eb\u30fc\u30d7\u3092\u8996\u899a\u7684\u306b\u8a8d\u8b58\u3067\u304d\u3001\u4f5c\u696d\u52b9\u7387\u304c\u30b0\u30c3\u3068\u30a2\u30c3\u30d7\u3057\u307e\u3059\uff01<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Google \u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u300c\u540c\u3058\u5024\u304c\u9023\u7d9a\u3057\u3066\u3044\u308b\u884c\u300d\u3092\u8996\u899a\u7684\u306b\u308f\u304b\u308a\u3084\u3059\u304f\u3057\u305f\u3044\u3053\u3068\u3063\u3066\u3042\u308a\u307e\u305b\u3093\u304b\uff1f \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b A\u5217\u306b\u30b0\u30eb\u30fc\u30d7\u304c\u4e26\u3093\u3067\u3044\u308b\u3068\u3057\u307e\u3059\u3002 \u3053\u306e\u3088\u3046\u306a\u300c\u540c\u3058\u5024\u304c\u9023\u7d9a\u3057\u3066\u3044\u308b\u884c\u300d\u3092 \u30b0\u30eb\u30fc\u30d7\u3054 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":22940,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[17],"tags":[18,9],"class_list":["post-22939","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spreadsheets","tag-gas","tag-free"],"_links":{"self":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/22939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/comments?post=22939"}],"version-history":[{"count":1,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/22939\/revisions"}],"predecessor-version":[{"id":22942,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/posts\/22939\/revisions\/22942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/media\/22940"}],"wp:attachment":[{"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/media?parent=22939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/categories?post=22939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cg-method.com\/google\/wp-json\/wp\/v2\/tags?post=22939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}