{"id":19362,"date":"2025-09-22T11:34:15","date_gmt":"2025-09-22T02:34:15","guid":{"rendered":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/?p=19362"},"modified":"2026-03-18T16:03:39","modified_gmt":"2026-03-18T07:03:39","slug":"%e3%82%b9%e3%83%97%e3%83%ac%e3%83%83%e3%83%89%e3%82%b7%e3%83%bc%e3%83%88%e3%81%a7%e5%88%a5%e3%82%b7%e3%83%bc%e3%83%88%e3%81%ae%e5%86%85%e5%ae%b9%e3%82%92%e8%87%aa%e5%8b%95%e5%8f%8d%e6%98%a0%e3%81%95","status":"publish","type":"post","link":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/19362\/","title":{"rendered":"\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u5225\u30b7\u30fc\u30c8\u306e\u5185\u5bb9\u3092\u81ea\u52d5\u53cd\u6620\u3055\u305b\u308b\u306b\u306f\uff1f\u95a2\u6570\u3084GAS\u3092\u4f7f\u3046\u65b9\u6cd5"},"content":{"rendered":"<p>\u8907\u6570\u306e\u30b7\u30fc\u30c8\u306b\u6563\u3089\u3070\u3063\u305f\u30c7\u30fc\u30bf\u3092\u96c6\u7d04\u3057\u305f\u3044\u3001\u5225\u30b7\u30fc\u30c8\u306e\u66f4\u65b0\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u53cd\u6620\u3055\u305b\u305f\u3044\u3068\u3044\u3063\u305f\u30cb\u30fc\u30ba\u306f\u3001\u65e5\u3005\u306e\u696d\u52d9\u3067\u3088\u304f\u767a\u751f\u3057\u307e\u3059\u3002Google\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u306f\u3001\u95a2\u6570\u3084Google Apps Script\uff08GAS\uff09\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b7\u30fc\u30c8\u9593\u306e\u30c7\u30fc\u30bf\u9023\u643a\u3092\u81ea\u52d5\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001\u57fa\u672c\u7684\u306a\u95a2\u6570\u3092\u4f7f\u3063\u305f\u65b9\u6cd5\u304b\u3089\u3001\u3088\u308a\u9ad8\u5ea6\u306aGAS\u306b\u3088\u308b\u81ea\u52d5\u5316\u307e\u3067\u3001\u5b9f\u52d9\u3067\u5373\u5ea7\u306b\u6d3b\u7528\u3067\u304d\u308b\u624b\u6cd5\u3092\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002\u624b\u4f5c\u696d\u306b\u3088\u308b\u30b3\u30d4\u30fc&amp;\u30da\u30fc\u30b9\u30c8\u304b\u3089\u8131\u5374\u3057\u3001\u52b9\u7387\u7684\u306a\u30c7\u30fc\u30bf\u7ba1\u7406\u3092\u5b9f\u73fe\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<div id=\"post-below-intro\"><\/div><h2>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u5225\u30b7\u30fc\u30c8\u306e\u5185\u5bb9\u3092\u81ea\u52d5\u53cd\u6620\u3055\u305b\u308b\u65b9\u6cd5<\/h2>\n<p><span style=\"background-color: #ffff99;\"><b>\u30c7\u30fc\u30bf\u306e\u81ea\u52d5\u53cd\u6620\u306f\u3001\u696d\u52d9\u52b9\u7387\u5316\u306e\u91cd\u8981\u306a\u8981\u7d20\u3067\u3059\u3002<\/b><\/span>\u58f2\u4e0a\u30c7\u30fc\u30bf\u3092\u6708\u5225\u30b7\u30fc\u30c8\u3067\u7ba1\u7406\u3057\u3001\u5e74\u9593\u96c6\u8a08\u30b7\u30fc\u30c8\u306b\u81ea\u52d5\u53cd\u6620\u3055\u305b\u308b\u3001\u8907\u6570\u306e\u90e8\u7f72\u304b\u3089\u306e\u30c7\u30fc\u30bf\u3092\u7d71\u5408\u30b7\u30fc\u30c8\u306b\u307e\u3068\u3081\u308b\u306a\u3069\u3001\u6d3b\u7528\u30b7\u30fc\u30f3\u306f\u591a\u5c90\u306b\u308f\u305f\u308a\u307e\u3059\u3002<\/p>\n<p>\u81ea\u52d5\u53cd\u6620\u306e\u4ed5\u7d44\u307f\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u4e8c\u91cd\u5165\u529b\u3092\u9632\u304e\u3001\u5165\u529b\u30df\u30b9\u3092\u524a\u6e1b\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u5e38\u306b\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u304c\u53cd\u6620\u3055\u308c\u308b\u305f\u3081\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u306e\u72b6\u6cc1\u628a\u63e1\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u6280\u8853\u30ec\u30d9\u30eb\u306b\u5fdc\u3058\u3066\u9078\u629e\u3067\u304d\u308b\u8907\u6570\u306e\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u6a19\u6e96\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u77e5\u8b58\u304c\u306a\u304f\u3066\u3082\u5b9f\u88c5\u3067\u304d\u308b\u6700\u3082\u624b\u8efd\u306a\u65b9\u6cd5\u3067\u3059\u3002<\/b><\/span>\u7528\u9014\u306b\u5fdc\u3058\u3066\u9069\u5207\u306a\u95a2\u6570\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u3001\u69d8\u3005\u306a\u30c7\u30fc\u30bf\u9023\u643a\u306e\u30cb\u30fc\u30ba\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u57fa\u672c\u7684\u306a\u53c2\u7167\u95a2\u6570\u3067\u306e\u9023\u643a<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>\u6700\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u65b9\u6cd5\u306f\u3001\u30bb\u30eb\u53c2\u7167\u3092\u4f7f\u3063\u305f\u76f4\u63a5\u7684\u306a\u9023\u643a\u3067\u3059\u3002<\/b><\/span>\u4ed6\u306e\u30b7\u30fc\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3059\u308b\u969b\u306e\u57fa\u672c\u7684\u306a\u8a18\u6cd5\u3068\u6d3b\u7528\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u5358\u4e00\u30bb\u30eb\u306e\u53c2\u7167<\/h4>\n<p>\u5225\u30b7\u30fc\u30c8\u306e\u7279\u5b9a\u306e\u30bb\u30eb\u3092\u53c2\u7167\u3059\u308b\u5834\u5408\u3001\u300c=\u30b7\u30fc\u30c8\u540d!\u30bb\u30eb\u756a\u5730\u300d\u3068\u3044\u3046\u5f62\u5f0f\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u300c\u58f2\u4e0a\u30c7\u30fc\u30bf\u300d\u30b7\u30fc\u30c8\u306eA1\u30bb\u30eb\u3092\u53c2\u7167\u3059\u308b\u5834\u5408\u306f\u3001\u300c=\u58f2\u4e0a\u30c7\u30fc\u30bf!A1\u300d\u3068\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b7\u30fc\u30c8\u540d\u306b\u30b9\u30da\u30fc\u30b9\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306f\u3001\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u300c=&#8217;\u6708\u6b21 \u58f2\u4e0a&#8217;!A1\u300d\u306e\u3088\u3046\u306a\u5f62\u5f0f\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u57fa\u672c\u7684\u306a\u53c2\u7167\u65b9\u6cd5\u306f\u3001\u7279\u5b9a\u306e\u5408\u8a08\u5024\u3084\u91cd\u8981\u306a\u6307\u6a19\u3092\u5225\u30b7\u30fc\u30c8\u306b\u8868\u793a\u3059\u308b\u969b\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u7bc4\u56f2\u53c2\u7167\u306e\u6d3b\u7528<\/h4>\n<p>\u8907\u6570\u306e\u30bb\u30eb\u3092\u307e\u3068\u3081\u3066\u53c2\u7167\u3059\u308b\u5834\u5408\u306f\u3001\u7bc4\u56f2\u6307\u5b9a\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u300c=\u58f2\u4e0a\u30c7\u30fc\u30bf!A1:C10\u300d\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001\u6307\u5b9a\u3057\u305f\u7bc4\u56f2\u5168\u4f53\u3092\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u65b9\u6cd5\u306f\u3001\u8868\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u5225\u30b7\u30fc\u30c8\u306b\u53cd\u6620\u3055\u305b\u305f\u3044\u5834\u5408\u306b\u6709\u52b9\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u5143\u306e\u30b7\u30fc\u30c8\u3067\u884c\u3084\u5217\u304c\u8ffd\u52a0\u30fb\u524a\u9664\u3055\u308c\u305f\u5834\u5408\u3001\u53c2\u7167\u7bc4\u56f2\u3082\u624b\u52d5\u3067\u8abf\u6574\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u70b9\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h4>STEP3\uff1a\u52d5\u7684\u306a\u53c2\u7167\u306e\u5b9f\u73fe<\/h4>\n<p>INDIRECT\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u3088\u308a\u67d4\u8edf\u306a\u53c2\u7167\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u300c=INDIRECT(&#8220;\u30b7\u30fc\u30c8&#8221;&amp;A1&amp;&#8221;!B2&#8243;)\u300d\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u3001A1\u30bb\u30eb\u306e\u5024\u306b\u5fdc\u3058\u3066\u53c2\u7167\u3059\u308b\u30b7\u30fc\u30c8\u3092\u52d5\u7684\u306b\u5909\u66f4\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u624b\u6cd5\u306f\u3001\u6708\u6b21\u30c7\u30fc\u30bf\u306e\u3088\u3046\u306b\u5b9a\u671f\u7684\u306b\u65b0\u3057\u3044\u30b7\u30fc\u30c8\u304c\u8ffd\u52a0\u3055\u308c\u308b\u74b0\u5883\u3067\u7279\u306b\u6709\u7528\u3067\u3059\u3002\u30b7\u30fc\u30c8\u540d\u306e\u4e00\u90e8\u3092\u5909\u6570\u5316\u3059\u308b\u3053\u3068\u3067\u3001\u53c2\u7167\u5148\u3092\u7c21\u5358\u306b\u5207\u308a\u66ff\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<h3>IMPORTRANGE\u95a2\u6570\u306b\u3088\u308b\u5916\u90e8\u30d5\u30a1\u30a4\u30eb\u9023\u643a<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>\u7570\u306a\u308b\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u9593\u3067\u30c7\u30fc\u30bf\u3092\u9023\u643a\u3059\u308b\u5834\u5408\u306f\u3001IMPORTRANGE\u95a2\u6570\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/b><\/span>\u3053\u306e\u95a2\u6570\u306f\u3001\u5225\u306eGoogle\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u8fbc\u3080\u5f37\u529b\u306a\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n<p>IMPORTRANGE\u95a2\u6570\u306e\u57fa\u672c\u69cb\u6587\u306f\u300c=IMPORTRANGE(&#8220;\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306eURL&#8221;, &#8220;\u7bc4\u56f2&#8221;)\u300d\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u300c=IMPORTRANGE(&#8220;https:\/\/docs.google.com\/spreadsheets\/d\/xxxxx&#8221;, &#8220;Sheet1!A1:C10&#8221;)\u300d\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u521d\u56de\u4f7f\u7528\u6642\u306f\u3001\u30c7\u30fc\u30bf\u3078\u306e\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u3092\u6c42\u3081\u308b\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u300c\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u53d6\u308a\u8fbc\u307f\u304c\u958b\u59cb\u3055\u308c\u307e\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u52d5\u7684\u306a\u7bc4\u56f2\u6307\u5b9a<\/h4>\n<p>IMPORTRANGE\u95a2\u6570\u3067\u3082\u52d5\u7684\u306a\u7bc4\u56f2\u6307\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u53d6\u308a\u8fbc\u3080\u7bc4\u56f2\u3092\u5225\u306e\u30bb\u30eb\u3067\u7ba1\u7406\u3059\u308b\u3053\u3068\u3067\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u7bc4\u56f2\u3092\u5909\u66f4\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=IMPORTRANGE(&#8220;URL&#8221;, CONCATENATE(A1,&#8221;!&#8221;,B1,&#8221;:&#8221;,C1))\u300d\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u3001A1\u306b\u30b7\u30fc\u30c8\u540d\u3001B1\u306b\u958b\u59cb\u30bb\u30eb\u3001C1\u306b\u7d42\u4e86\u30bb\u30eb\u3092\u5165\u529b\u3059\u308b\u3053\u3068\u3067\u3001\u67d4\u8edf\u306a\u904b\u7528\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>STEP3\uff1a\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u5b9f\u88c5<\/h4>\n<p>IMPORTRANGE\u95a2\u6570\u306f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u3084\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u306e\u554f\u984c\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002IFERROR\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc\u6642\u306e\u8868\u793a\u3092\u5236\u5fa1\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=IFERROR(IMPORTRANGE(&#8230;), &#8220;\u30c7\u30fc\u30bf\u53d6\u5f97\u30a8\u30e9\u30fc&#8221;)\u300d\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc\u767a\u751f\u6642\u306b\u30e6\u30fc\u30b6\u30fc\u30d5\u30ec\u30f3\u30c9\u30ea\u30fc\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>QUERY\u95a2\u6570\u3092\u4f7f\u3063\u305f\u9ad8\u5ea6\u306a\u30c7\u30fc\u30bf\u62bd\u51fa<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>QUERY\u95a2\u6570\u3092\u4f7f\u3046\u3068\u3001SQL\u98a8\u306e\u69cb\u6587\u3067\u62bd\u51fa\u3084\u96c6\u8a08\u304c\u3067\u304d\u307e\u3059\u3002<\/b><\/span>\u5916\u90e8\u30b7\u30fc\u30c8\u3084\u4ed6\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046\u5834\u5408\u306fIMPORTRANGE\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5927\u91cf\u306e\u30c7\u30fc\u30bf\u304b\u3089\u5fc5\u8981\u306a\u60c5\u5831\u3060\u3051\u3092\u52b9\u7387\u7684\u306b\u53d6\u308a\u51fa\u3059\u5834\u5408\u306b\u6700\u9069\u3067\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u57fa\u672c\u7684\u306a\u30af\u30a8\u30ea\u306e\u4f5c\u6210<\/h4>\n<p>QUERY\u95a2\u6570\u306e\u57fa\u672c\u69cb\u6587\u306f\u300c=QUERY(\u30c7\u30fc\u30bf\u7bc4\u56f2, &#8220;\u30af\u30a8\u30ea\u6587\u5b57\u5217&#8221;)\u300d\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u58f2\u4e0a\u30c7\u30fc\u30bf\u304b\u3089\u7279\u5b9a\u306e\u6761\u4ef6\u306b\u5408\u81f4\u3059\u308b\u30c7\u30fc\u30bf\u3060\u3051\u3092\u62bd\u51fa\u3059\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u300c=QUERY(\u58f2\u4e0a\u30c7\u30fc\u30bf!A:E, &#8220;SELECT * WHERE C &gt; 100000&#8221;)\u300d\u3053\u306e\u4f8b\u3067\u306f\u3001C\u5217\uff08\u58f2\u4e0a\u91d1\u984d\uff09\u304c10\u4e07\u5186\u3092\u8d85\u3048\u308b\u30c7\u30fc\u30bf\u306e\u307f\u3092\u62bd\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u8907\u6570\u6761\u4ef6\u3067\u306e\u7d5e\u308a\u8fbc\u307f<\/h4>\n<p>\u3088\u308a\u8907\u96d1\u306a\u6761\u4ef6\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002AND\u3001OR\u3001NOT\u306a\u3069\u306e\u8ad6\u7406\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u6761\u4ef6\u3092\u7d44\u307f\u5408\u308f\u305b\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u300c=QUERY(\u58f2\u4e0a\u30c7\u30fc\u30bf!A:E, &#8220;SELECT A, B, C WHERE C &gt; 100000 AND D = &#8216;\u6771\u4eac\u652f\u5e97&#8217; ORDER BY C DESC&#8221;)\u300d\u3053\u306e\u30af\u30a8\u30ea\u3067\u306f\u3001\u58f2\u4e0a\u91d1\u984d\u304c10\u4e07\u5186\u8d85\u304b\u3064\u6771\u4eac\u652f\u5e97\u306e\u30c7\u30fc\u30bf\u3092\u3001\u58f2\u4e0a\u91d1\u984d\u306e\u964d\u9806\u3067\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>STEP3\uff1a\u96c6\u8a08\u6a5f\u80fd\u306e\u6d3b\u7528<\/h4>\n<p>QUERY\u95a2\u6570\u306f\u96c6\u8a08\u6a5f\u80fd\u3082\u5099\u3048\u3066\u3044\u307e\u3059\u3002GROUP BY\u53e5\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u96c6\u8a08\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=QUERY(\u58f2\u4e0a\u30c7\u30fc\u30bf!A:E, &#8220;SELECT D, SUM(C) GROUP BY D&#8221;)\u300d\u3053\u306e\u4f8b\u3067\u306f\u3001\u652f\u5e97\u5225\uff08D\u5217\uff09\u306b\u58f2\u4e0a\u91d1\u984d\uff08C\u5217\uff09\u3092\u5408\u8a08\u3057\u3066\u3044\u307e\u3059\u3002\u6708\u6b21\u96c6\u8a08\u3084\u90e8\u9580\u5225\u96c6\u8a08\u306a\u3069\u3001\u69d8\u3005\u306a\u5207\u308a\u53e3\u3067\u306e\u30c7\u30fc\u30bf\u5206\u6790\u306b\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>ARRAYFORMULA\u95a2\u6570\u3067\u306e\u4e00\u62ec\u51e6\u7406<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>ARRAYFORMULA\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u914d\u5217\u5f62\u5f0f\u3067\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3057\u3001\u8907\u6570\u306e\u30bb\u30eb\u306b\u4e00\u5ea6\u306b\u7d50\u679c\u3092\u53cd\u6620\u3067\u304d\u307e\u3059\u3002<\/b><\/span>\u5927\u91cf\u306e\u30c7\u30fc\u30bf\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u969b\u306b\u5a01\u529b\u3092\u767a\u63ee\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u57fa\u672c\u7684\u306a\u914d\u5217\u51e6\u7406<\/h4>\n<p>\u901a\u5e38\u306e\u95a2\u6570\u3067\u306f1\u3064\u306e\u30bb\u30eb\u3054\u3068\u306b\u6570\u5f0f\u3092\u5165\u529b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001ARRAYFORMULA\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u7bc4\u56f2\u5168\u4f53\u306b\u5bfe\u3057\u3066\u4e00\u5ea6\u306b\u51e6\u7406\u3092\u9069\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=ARRAYFORMULA(\u58f2\u4e0a\u30c7\u30fc\u30bf!A2:A100 &amp; &#8221; &#8211; &#8221; &amp; \u58f2\u4e0a\u30c7\u30fc\u30bf!B2:B100)\u300d\u3053\u306e\u4f8b\u3067\u306f\u3001A\u5217\u3068B\u5217\u306e\u5024\u3092\u7d50\u5408\u3057\u3066\u3001\u65b0\u3057\u3044\u5217\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002100\u884c\u5206\u306e\u30c7\u30fc\u30bf\u30921\u3064\u306e\u6570\u5f0f\u3067\u51e6\u7406\u3067\u304d\u308b\u305f\u3081\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u6761\u4ef6\u4ed8\u304d\u51e6\u7406\u306e\u5b9f\u88c5<\/h4>\n<p>IF\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u6761\u4ef6\u306b\u5fdc\u3058\u305f\u51e6\u7406\u3092\u914d\u5217\u5168\u4f53\u306b\u9069\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=ARRAYFORMULA(IF(\u58f2\u4e0a\u30c7\u30fc\u30bf!C2:C100 &gt; 100000, &#8220;\u5927\u53e3&#8221;, &#8220;\u901a\u5e38&#8221;))\u300d\u58f2\u4e0a\u91d1\u984d\u306b\u5fdc\u3058\u3066\u9867\u5ba2\u3092\u5206\u985e\u3059\u308b\u51e6\u7406\u3092\u3001\u5168\u884c\u306b\u5bfe\u3057\u3066\u4e00\u62ec\u3067\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>STEP3\uff1a\u52d5\u7684\u306a\u7bc4\u56f2\u3067\u306e\u6d3b\u7528<\/h4>\n<p>ARRAYFORMULA\u95a2\u6570\u306f\u3001\u30c7\u30fc\u30bf\u306e\u5897\u6e1b\u306b\u5bfe\u5fdc\u3059\u308b\u52d5\u7684\u306a\u51e6\u7406\u306b\u3082\u9069\u3057\u3066\u3044\u307e\u3059\u3002COUNTA\u95a2\u6570\u306a\u3069\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u7bc4\u56f2\u3060\u3051\u3092\u51e6\u7406\u5bfe\u8c61\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u300c=ARRAYFORMULA(IF(LEN(A2:A), \u58f2\u4e0a\u30c7\u30fc\u30bf!A2:A * 1.1, &#8220;&#8221;))\u300d\u3053\u306e\u4f8b\u3067\u306f\u3001A\u5217\u306b\u30c7\u30fc\u30bf\u304c\u3042\u308b\u884c\u3060\u3051\u306b\u5bfe\u3057\u3066\u300110%\u5897\u3057\u306e\u8a08\u7b97\u3092\u9069\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>GAS\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>Google Apps Script\uff08GAS\uff09\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u3088\u308a\u9ad8\u5ea6\u3067\u67d4\u8edf\u306a\u81ea\u52d5\u5316\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/b><\/span>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u77e5\u8b58\u306f\u5fc5\u8981\u3067\u3059\u304c\u3001\u95a2\u6570\u3067\u306f\u5b9f\u73fe\u3067\u304d\u306a\u3044\u8907\u96d1\u306a\u51e6\u7406\u3084\u3001\u5b9a\u671f\u7684\u306a\u81ea\u52d5\u5b9f\u884c\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>GAS\u306e\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u3068\u6e96\u5099<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>GAS\u3092\u4f7f\u3044\u59cb\u3081\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u624b\u9806\u3068\u3001\u958b\u767a\u74b0\u5883\u306e\u6e96\u5099\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/b><\/span><\/p>\n<h4>STEP1\uff1a\u30b9\u30af\u30ea\u30d7\u30c8\u30a8\u30c7\u30a3\u30bf\u3078\u306e\u30a2\u30af\u30bb\u30b9<\/h4>\n<p>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u300c\u62e1\u5f35\u6a5f\u80fd\u300d\u2192\u300cApps Script\u300d\u3092\u9078\u629e\u3059\u308b\u3068\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30a8\u30c7\u30a3\u30bf\u304c\u958b\u304d\u307e\u3059\u3002\u3053\u3053\u3067JavaScript\u30d9\u30fc\u30b9\u306e\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u521d\u3081\u3066GAS\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u306e\u8a8d\u8a3c\u304c\u5fc5\u8981\u3067\u3059\u3002\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u66f8\u304d\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u8aad\u307f\u66f8\u304d<\/h4>\n<p>GAS\u3067\u30b7\u30fc\u30c8\u9593\u306e\u30c7\u30fc\u30bf\u3092\u30b3\u30d4\u30fc\u3059\u308b\u57fa\u672c\u7684\u306a\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>function copyData() {<\/p>\n<p>var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u5143\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u53cd\u6620\u5148&#8217;);<\/p>\n<p>var sourceData = sourceSheet.getRange(&#8216;A1:C10&#8217;).getValues();<\/p>\n<p>targetSheet.getRange(&#8216;A1:C10&#8217;).setValues(sourceData);}<\/p>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u300c\u5143\u30c7\u30fc\u30bf\u300d\u30b7\u30fc\u30c8\u306eA1:C10\u306e\u7bc4\u56f2\u3092\u300c\u53cd\u6620\u5148\u300d\u30b7\u30fc\u30c8\u306e\u540c\u3058\u7bc4\u56f2\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP3\uff1a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5<\/h4>\n<p>\u5b9f\u52d9\u3067\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u3084\u30c7\u30fc\u30bf\u5f62\u5f0f\u304c\u7570\u306a\u308b\u5834\u5408\u306b\u5099\u3048\u3066\u3001try-catch\u6587\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>function safeCopyData() {<\/p>\n<p>try {<\/p>\n<p>var ss = SpreadsheetApp.getActiveSpreadsheet();<\/p>\n<p>var sourceSheet = ss.getSheetByName(&#8216;\u5143\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var targetSheet = ss.getSheetByName(&#8216;\u53cd\u6620\u5148&#8217;);<\/p>\n<p>if (!sourceSheet || !targetSheet) {<\/p>\n<p>throw new Error(&#8216;\u6307\u5b9a\u3055\u308c\u305f\u30b7\u30fc\u30c8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093&#8217;);\u00a0}<\/p>\n<p>var sourceData = sourceSheet.getDataRange().getValues();<\/p>\n<p>targetSheet.clear();<\/p>\n<p>targetSheet.getRange(1, 1, sourceData.length, sourceData[0].length).setValues(sourceData);<\/p>\n<p>} catch (e) {<\/p>\n<p>SpreadsheetApp.getUi().alert(&#8216;\u30a8\u30e9\u30fc: &#8216; + e.message);\u00a0}}<\/p>\n<h3>\u6761\u4ef6\u4ed8\u304d\u30c7\u30fc\u30bf\u53cd\u6620\u306e\u5b9f\u88c5<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>GAS\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u8907\u96d1\u306a\u6761\u4ef6\u306b\u57fa\u3065\u3044\u305f\u30c7\u30fc\u30bf\u306e\u62bd\u51fa\u3084\u52a0\u5de5\u304c\u53ef\u80fd\u3067\u3059\u3002<\/b><\/span>\u5b9f\u52d9\u3067\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u6761\u4ef6\u4ed8\u304d\u53cd\u6620\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u7279\u5b9a\u6761\u4ef6\u3067\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0<\/h4>\n<p>\u58f2\u4e0a\u30c7\u30fc\u30bf\u304b\u3089\u7279\u5b9a\u306e\u6761\u4ef6\u306b\u5408\u81f4\u3059\u308b\u30c7\u30fc\u30bf\u3060\u3051\u3092\u5225\u30b7\u30fc\u30c8\u306b\u53cd\u6620\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n<p>function filterAndCopy() {<\/p>\n<p>var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u5168\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u62bd\u51fa\u7d50\u679c&#8217;);<\/p>\n<p>var sourceData = sourceSheet.getDataRange().getValues();<\/p>\n<p>var filteredData = [sourceData[0]]; \/\/ \u30d8\u30c3\u30c0\u30fc\u884c\u3092\u4fdd\u6301<\/p>\n<p>for (var i = 1; i &lt; sourceData.length; i++) {<\/p>\n<p>if (sourceData[i][2] &gt; 100000) { \/\/ 3\u5217\u76ee\uff08\u58f2\u4e0a\u91d1\u984d\uff09\u304c10\u4e07\u5186\u8d85<\/p>\n<p>filteredData.push(sourceData[i]);\u00a0}}<\/p>\n<p>targetSheet.clear();<\/p>\n<p>targetSheet.getRange(1, 1, filteredData.length, filteredData[0].length).setValues(filteredData);}<\/p>\n<h4>STEP2\uff1a\u8907\u6570\u30b7\u30fc\u30c8\u304b\u3089\u306e\u30c7\u30fc\u30bf\u7d71\u5408<\/h4>\n<p>\u8907\u6570\u306e\u90e8\u9580\u5225\u30b7\u30fc\u30c8\u304b\u3089\u3001\u30c7\u30fc\u30bf\u3092\u7d71\u5408\u30b7\u30fc\u30c8\u306b\u96c6\u7d04\u3059\u308b\u51e6\u7406\u3067\u3059\u3002<\/p>\n<p>function consolidateSheets() {<\/p>\n<p>var ss = SpreadsheetApp.getActiveSpreadsheet();<\/p>\n<p>var targetSheet = ss.getSheetByName(&#8216;\u7d71\u5408\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var departmentSheets = [&#8216;\u55b6\u696d\u90e8&#8217;, &#8216;\u958b\u767a\u90e8&#8217;, &#8216;\u7ba1\u7406\u90e8&#8217;];<\/p>\n<p>targetSheet.clear();<\/p>\n<p>var allData = [];<\/p>\n<p>var isFirstSheet = true;<\/p>\n<p>departmentSheets.forEach(function(sheetName) {<\/p>\n<p>var sheet = ss.getSheetByName(sheetName);<\/p>\n<p>if (sheet) {<\/p>\n<p>var data = sheet.getDataRange().getValues();<\/p>\n<p>if (isFirstSheet) {<\/p>\n<p>allData = allData.concat(data); \/\/ \u30d8\u30c3\u30c0\u30fc\u542b\u3080<\/p>\n<p>isFirstSheet = false;<\/p>\n<p>} else {<\/p>\n<p>allData = allData.concat(data.slice(1)); \/\/ \u30d8\u30c3\u30c0\u30fc\u9664\u304f}}\u00a0});<\/p>\n<p>if (allData.length &gt; 0) {<\/p>\n<p>targetSheet.getRange(1, 1, allData.length, allData[0].length).setValues(allData);}}<\/p>\n<h4>STEP3\uff1a\u30c7\u30fc\u30bf\u306e\u52a0\u5de5\u3068\u5909\u63db<\/h4>\n<p>\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3057\u3066\u304b\u3089\u53cd\u6620\u3059\u308b\u51e6\u7406\u3082\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>function transformAndCopy() {<\/p>\n<p>var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u539f\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u52a0\u5de5\u6e08\u307f\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var sourceData = sourceSheet.getDataRange().getValues();<\/p>\n<p>var transformedData = [];<\/p>\n<p>\/\/ \u30d8\u30c3\u30c0\u30fc\u884c\u306e\u4f5c\u6210<\/p>\n<p>transformedData.push([&#8216;\u65e5\u4ed8&#8217;, &#8216;\u5546\u54c1\u540d&#8217;, &#8216;\u6570\u91cf&#8217;, &#8216;\u5358\u4fa1&#8217;, &#8216;\u58f2\u4e0a\u91d1\u984d&#8217;, &#8216;\u7a0e\u8fbc\u91d1\u984d&#8217;]);<\/p>\n<p>\/\/ \u30c7\u30fc\u30bf\u306e\u52a0\u5de5<\/p>\n<p>for (var i = 1; i &lt; sourceData.length; i++) {<\/p>\n<p>var row = sourceData[i];<\/p>\n<p>var salesAmount = row[2] * row[3]; \/\/ \u6570\u91cf \u00d7 \u5358\u4fa1<\/p>\n<p>var taxIncluded = salesAmount * 1.1; \/\/ \u7a0e\u8fbc\u8a08\u7b97<\/p>\n<p>transformedData.push([<\/p>\n<p>row[0], \/\/ \u65e5\u4ed8<\/p>\n<p>row[1], \/\/ \u5546\u54c1\u540d<\/p>\n<p>row[2], \/\/ \u6570\u91cf<\/p>\n<p>row[3], \/\/ \u5358\u4fa1<\/p>\n<p>salesAmount, \/\/ \u58f2\u4e0a\u91d1\u984d<\/p>\n<p>taxIncluded \/\/ \u7a0e\u8fbc\u91d1\u984d<\/p>\n<p>]);\u00a0}<\/p>\n<p>targetSheet.clear();<\/p>\n<p>targetSheet.getRange(1, 1, transformedData.length, transformedData[0].length).setValues(transformedData);}<\/p>\n<h3>\u30c8\u30ea\u30ac\u30fc\u306b\u3088\u308b\u81ea\u52d5\u5b9f\u884c\u306e\u8a2d\u5b9a<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>GAS\u306e\u5927\u304d\u306a\u5229\u70b9\u306f\u3001\u30c8\u30ea\u30ac\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u5b9a\u671f\u7684\u306a\u81ea\u52d5\u5b9f\u884c\u304c\u53ef\u80fd\u306b\u306a\u308b\u3053\u3068\u3067\u3059\u3002<\/b><\/span>\u6642\u9593\u30d9\u30fc\u30b9\u306e\u30c8\u30ea\u30ac\u30fc\u3084\u30a4\u30d9\u30f3\u30c8\u30d9\u30fc\u30b9\u306e\u30c8\u30ea\u30ac\u30fc\u306e\u8a2d\u5b9a\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP1\uff1a\u6642\u9593\u30d9\u30fc\u30b9\u30c8\u30ea\u30ac\u30fc\u306e\u8a2d\u5b9a<\/h4>\n<p>\u6bce\u65e5\u6c7a\u307e\u3063\u305f\u6642\u523b\u306b\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408\u306e\u8a2d\u5b9a\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>function setupTimeTrigger() {<\/p>\n<p>ScriptApp.newTrigger(&#8216;dailyDataUpdate&#8217;)<\/p>\n<p>.timeBased()<\/p>\n<p>.everyDays(1)<\/p>\n<p>.atHour(9)<\/p>\n<p>.create();}<\/p>\n<p>function dailyDataUpdate() {<\/p>\n<p>\/\/ \u3053\u3053\u306b\u5b9a\u671f\u5b9f\u884c\u3057\u305f\u3044\u51e6\u7406\u3092\u8a18\u8ff0<\/p>\n<p>copyData();<\/p>\n<p>\/\/ \u5b9f\u884c\u30ed\u30b0\u306e\u8a18\u9332<\/p>\n<p>var logSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u5b9f\u884c\u30ed\u30b0&#8217;);<\/p>\n<p>var timestamp = new Date();<\/p>\n<p>logSheet.appendRow([timestamp, &#8216;\u65e5\u6b21\u66f4\u65b0\u5b8c\u4e86&#8217;]);}<\/p>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u6bce\u65e5\u5348\u524d9\u6642\u306bdailyDataUpdate\u95a2\u6570\u304c\u81ea\u52d5\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<h4>STEP2\uff1a\u7de8\u96c6\u6642\u30c8\u30ea\u30ac\u30fc\u306e\u5b9f\u88c5<\/h4>\n<p>\u7279\u5b9a\u306e\u30b7\u30fc\u30c8\u304c\u7de8\u96c6\u3055\u308c\u305f\u3068\u304d\u306b\u3001\u81ea\u52d5\u7684\u306b\u4ed6\u306e\u30b7\u30fc\u30c8\u3092\u66f4\u65b0\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n<p>function onEdit(e) {<\/p>\n<p>var editedSheet = e.source.getActiveSheet();<\/p>\n<p>var editedRange = e.range;<\/p>\n<p>\/\/ \u7279\u5b9a\u306e\u30b7\u30fc\u30c8\u304c\u7de8\u96c6\u3055\u308c\u305f\u5834\u5408\u306e\u307f\u51e6\u7406<\/p>\n<p>if (editedSheet.getName() === &#8216;\u30de\u30b9\u30bf\u30fc\u30c7\u30fc\u30bf&#8217;) {<\/p>\n<p>updateDependentSheets();}}<\/p>\n<p>function updateDependentSheets() {<\/p>\n<p>var ss = SpreadsheetApp.getActiveSpreadsheet();<\/p>\n<p>var masterSheet = ss.getSheetByName(&#8216;\u30de\u30b9\u30bf\u30fc\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>var summarySheet = ss.getSheetByName(&#8216;\u30b5\u30de\u30ea\u30fc&#8217;);<\/p>\n<p>\/\/ \u30de\u30b9\u30bf\u30fc\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u3092\u53cd\u6620<\/p>\n<p>var masterData = masterSheet.getDataRange().getValues();<\/p>\n<p>\/\/ \u30b5\u30de\u30ea\u30fc\u30b7\u30fc\u30c8\u306e\u66f4\u65b0\u51e6\u7406<\/p>\n<p>updateSummary(summarySheet, masterData);}<\/p>\n<h4>STEP3\uff1a\u30a8\u30e9\u30fc\u901a\u77e5\u306e\u5b9f\u88c5<\/h4>\n<p>\u81ea\u52d5\u5b9f\u884c\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u30e1\u30fc\u30eb\u3067\u901a\u77e5\u3092\u53d7\u3051\u53d6\u308b\u4ed5\u7d44\u307f\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>function executeWithErrorNotification() {<\/p>\n<p>try {<\/p>\n<p>\/\/ \u30e1\u30a4\u30f3\u306e\u51e6\u7406<\/p>\n<p>consolidateSheets();<\/p>\n<p>} catch (error) {<\/p>\n<p>\/\/ \u30a8\u30e9\u30fc\u767a\u751f\u6642\u306e\u51e6\u7406<\/p>\n<p>var recipient = &#8216;alerts@example.com&#8217;; \/\/ \u53d7\u4fe1\u5148\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a<\/p>\n<p>var subject = &#8216;\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u81ea\u52d5\u66f4\u65b0\u30a8\u30e9\u30fc&#8217;;<\/p>\n<p>var body = &#8216;\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f:nn&#8217; + error.toString() + &#8216;nn&#8217; +<\/p>\n<p>&#8216;\u30d5\u30a1\u30a4\u30eb: &#8216; + SpreadsheetApp.getActiveSpreadsheet().getUrl();<\/p>\n<p>MailApp.sendEmail(recipient, subject, body);<\/p>\n<p>\/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a18\u9332\uff08\u7121\u3051\u308c\u3070\u4f5c\u6210\uff09<\/p>\n<p>var ss = SpreadsheetApp.getActiveSpreadsheet();<\/p>\n<p>var errorLog = ss.getSheetByName(&#8216;\u30a8\u30e9\u30fc\u30ed\u30b0&#8217;) || ss.insertSheet(&#8216;\u30a8\u30e9\u30fc\u30ed\u30b0&#8217;);<\/p>\n<p>errorLog.appendRow([new Date(), error.toString()]);}}<\/p>\n<p>\uff08\u88dc\u8db3\uff1a\u5b9b\u5148\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u7ba1\u7406\u3057\u305f\u3044\u5834\u5408\uff09<\/p>\n<p>var RECIPIENT_KEY = &#8216;ERROR_NOTIFY_TO&#8217;;<\/p>\n<p>function getRecipient_() {<\/p>\n<p>var props = PropertiesService.getScriptProperties();<\/p>\n<p>return props.getProperty(RECIPIENT_KEY) || &#8216;alerts@example.com&#8217;;}<\/p>\n<p>\u3068\u3057\u3066\u3001<\/p>\n<p>var recipient = getRecipient_();<\/p>\n<p>\u3068\u547c\u3073\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>\u5916\u90e8API\u3068\u306e\u9023\u643a<\/h3>\n<p><span style=\"background-color: #ffff99;\"><b>GAS\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u5916\u90e8\u306eAPI\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u53cd\u6620\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/b><\/span>\u5929\u6c17\u60c5\u5831\u3084\u70ba\u66ff\u30ec\u30fc\u30c8\u306a\u3069\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30c7\u30fc\u30bf\u306e\u6d3b\u7528\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h4>STEP1\uff1aURL\u30d5\u30a7\u30c3\u30c1\u3067\u306e\u30c7\u30fc\u30bf\u53d6\u5f97<\/h4>\n<p>\u5916\u90e8API\u304b\u3089JSON\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u57fa\u672c\u7684\u306a\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>function fetchExternalData() {<\/p>\n<p>var url = &#8216;https:\/\/api.example.com\/data&#8217;;<\/p>\n<p>var options = {<\/p>\n<p>&#8216;method&#8217;: &#8216;get&#8217;,<\/p>\n<p>&#8216;headers&#8217;: {<\/p>\n<p>&#8216;Authorization&#8217;: &#8216;Bearer YOUR_API_KEY&#8217;}};<\/p>\n<p>try {<\/p>\n<p>var response = UrlFetchApp.fetch(url, options);<\/p>\n<p>var jsonData = JSON.parse(response.getContentText());<\/p>\n<p>\/\/ \u30c7\u30fc\u30bf\u3092\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u307f<\/p>\n<p>writeJsonToSheet(jsonData);<\/p>\n<p>} catch (error) {<\/p>\n<p>console.error(&#8216;API\u53d6\u5f97\u30a8\u30e9\u30fc:&#8217;, error);}}<\/p>\n<p>function writeJsonToSheet(jsonData) {<\/p>\n<p>var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;API\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>sheet.clear();<\/p>\n<p>\/\/ JSON\u30c7\u30fc\u30bf\u30922\u6b21\u5143\u914d\u5217\u306b\u5909\u63db<\/p>\n<p>var dataArray = [];<\/p>\n<p>jsonData.forEach(function(item) {<\/p>\n<p>dataArray.push([item.date, item.value, item.status]);\u00a0});<\/p>\n<p>if (dataArray.length &gt; 0) {<\/p>\n<p>sheet.getRange(1, 1, dataArray.length, dataArray[0].length).setValues(dataArray);}}<\/p>\n<h4>STEP2\uff1a\u5b9a\u671f\u7684\u306a\u30c7\u30fc\u30bf\u66f4\u65b0<\/h4>\n<p>\u5916\u90e8\u30c7\u30fc\u30bf\u3092\u5b9a\u671f\u7684\u306b\u53d6\u5f97\u3057\u3066\u66f4\u65b0\u3059\u308b\u4ed5\u7d44\u307f\u306e\u5b9f\u88c5\u3067\u3059\u3002<\/p>\n<p>function setupApiDataRefresh() {<\/p>\n<p>\/\/ 1\u6642\u9593\u3054\u3068\u306bAPI\u30c7\u30fc\u30bf\u3092\u66f4\u65b0<\/p>\n<p>ScriptApp.newTrigger(&#8216;refreshApiData&#8217;)<\/p>\n<p>.timeBased()<\/p>\n<p>.everyHours(1)<\/p>\n<p>.create();}<\/p>\n<p>function refreshApiData() {<\/p>\n<p>fetchExternalData();<\/p>\n<p>\/\/ \u6700\u7d42\u66f4\u65b0\u6642\u523b\u3092\u8a18\u9332<\/p>\n<p>var infoSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u66f4\u65b0\u60c5\u5831&#8217;);<\/p>\n<p>var lastUpdate = new Date();<\/p>\n<p>infoSheet.getRange(&#8216;B1&#8217;).setValue(lastUpdate);<\/p>\n<h4>STEP3\uff1a\u8907\u6570\u30bd\u30fc\u30b9\u304b\u3089\u306e\u30c7\u30fc\u30bf\u7d71\u5408<\/h4>\n<p>\u8907\u6570\u306eAPI\u3084\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u304b\u3089\u60c5\u5831\u3092\u96c6\u7d04\u3059\u308b\u9ad8\u5ea6\u306a\u5b9f\u88c5\u4f8b\u3067\u3059\u3002<\/p>\n<p>function integrateMultipleSources() {<\/p>\n<p>var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#8216;\u7d71\u5408\u30c7\u30fc\u30bf&#8217;);<\/p>\n<p>sheet.clear();<\/p>\n<p>\/\/ \u8907\u6570\u306e\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3092\u5b9a\u7fa9<\/p>\n<p>var dataSources = [<\/p>\n<p>{name: &#8216;\u58f2\u4e0aAPI&#8217;, url: &#8216;https:\/\/api.sales.com\/data&#8217;, processor: processSalesData},<\/p>\n<p>{name: &#8216;\u5728\u5eabAPI&#8217;, url: &#8216;https:\/\/api.inventory.com\/data&#8217;, processor: processInventoryData},<\/p>\n<p>{name: &#8216;\u9867\u5ba2API&#8217;, url: &#8216;https:\/\/api.customers.com\/data&#8217;, processor: processCustomerData}];<\/p>\n<p>var allData = [];<\/p>\n<p>dataSources.forEach(function(source) {<\/p>\n<p>try {<\/p>\n<p>var response = UrlFetchApp.fetch(source.url);<\/p>\n<p>var data = JSON.parse(response.getContentText());<\/p>\n<p>var processedData = source.processor(data);<\/p>\n<p>allData = allData.concat(processedData);<\/p>\n<p>} catch (error) {<\/p>\n<p>console.error(source.name + &#8216;\u306e\u53d6\u5f97\u306b\u5931\u6557:&#8217;, error);}});<\/p>\n<p>\/\/ \u7d71\u5408\u30c7\u30fc\u30bf\u3092\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u307f<\/p>\n<p>if (allData.length &gt; 0) {<\/p>\n<p>sheet.getRange(1, 1, allData.length, allData[0].length).setValues(allData);\u00a0}}<\/p>\n<h2>\u95a2\u6570\u3068GAS\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u52b9\u7387\u7684\u306b\u30b7\u30fc\u30c8\u9023\u643a\u3057\u3088\u3046<\/h2>\n<p>Google\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u5225\u30b7\u30fc\u30c8\u306e\u5185\u5bb9\u3092\u81ea\u52d5\u53cd\u6620\u3059\u308b\u65b9\u6cd5\u306f\u3001\u76ee\u7684\u3084\u6271\u3046\u30c7\u30fc\u30bf\u91cf\u306b\u3088\u3063\u3066\u4f7f\u3044\u5206\u3051\u308b\u306e\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<p>\u30b7\u30f3\u30d7\u30eb\u306a\u53c2\u7167\u306a\u3089\u300c=\u30b7\u30fc\u30c8\u540d!\u30bb\u30eb\u756a\u5730\u300d\u3067\u5341\u5206\u3067\u3059\u304c\u3001\u8907\u6570\u7bc4\u56f2\u3084\u52d5\u7684\u306a\u53c2\u7167\u306b\u306fINDIRECT\u304c\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>\u5916\u90e8\u30d5\u30a1\u30a4\u30eb\u3068\u9023\u643a\u3059\u308b\u5834\u5408\u306fIMPORTRANGE\u3001\u6761\u4ef6\u4ed8\u304d\u3067\u62bd\u51fa\u30fb\u96c6\u8a08\u3059\u308b\u306a\u3089QUERY\u304c\u52b9\u679c\u7684\u3067\u3059\u3002\u3055\u3089\u306b\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u7d71\u5408\u3084\u5b9a\u671f\u66f4\u65b0\u306b\u306fGoogle Apps Script\uff08GAS\uff09\u3092\u4f7f\u3048\u3070\u81ea\u52d5\u5316\u306e\u5e45\u304c\u5e83\u304c\u308a\u307e\u3059\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306a\u95a2\u6570\u304b\u3089\u59cb\u3081\u3066\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066GAS\u3078\u30b9\u30c6\u30c3\u30d7\u30a2\u30c3\u30d7\u3059\u308b\u3053\u3068\u3067\u3001\u696d\u52d9\u306e\u52b9\u7387\u5316\u3068\u6b63\u78ba\u6027\u3092\u9ad8\u3081\u3089\u308c\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8907\u6570\u306e\u30b7\u30fc\u30c8\u306b\u6563\u3089\u3070\u3063\u305f\u30c7\u30fc\u30bf\u3092\u96c6\u7d04\u3057\u305f\u3044\u3001\u5225\u30b7\u30fc\u30c8\u306e\u66f4\u65b0\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u53cd\u6620\u3055\u305b\u305f\u3044\u3068\u3044\u3063\u305f\u30cb\u30fc\u30ba\u306f\u3001\u65e5\u3005\u306e\u696d\u52d9\u3067\u3088\u304f\u767a\u751f\u3057\u307e\u3059\u3002Google\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u306f\u3001\u95a2\u6570\u3084Google Apps Script\uff08GAS\uff09\u3092 [&hellip;]<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[51],"tags":[],"class_list":["post-19362","post","type-post","status-publish","format-standard","hentry","category-excel"],"acf":{"pdf-dlbox-url":"https:\/\/biz.moneyforward.com\/library\/form\/54620\/","templatesbox-title":"\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8","templatesbox-img1-url":"","templatesbox-img1-title":"","templatesbox-img2-url":"","templatesbox-img2-title":"","templatesbox-desc":"\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u7121\u6599\u3067\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\u305c\u3072\u3054\u81ea\u7531\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u6d3b\u7528\u304f\u3060\u3055\u3044\u3002","templatesbox-btn-text":"\u7121\u6599\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b","templatesbox-link":""},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/posts\/19362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/comments?post=19362"}],"version-history":[{"count":8,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/posts\/19362\/revisions"}],"predecessor-version":[{"id":19596,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/posts\/19362\/revisions\/19596"}],"wp:attachment":[{"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/media?parent=19362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/categories?post=19362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biz.moneyforward.com\/work-efficiency\/basic\/wp-json\/wp\/v2\/tags?post=19362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}