スプレッドシートで複数選択できるプルダウンを列全体に作成したい

実現したいこと

スプレッドシートで一列すべてのセルに
複数選択可能なプルダウンリストを作成したい

前提

顧客リストを管理しています。
ヒアリングした内容を項目の中から複数チェックして
チェックしたものだけセルに書き込まれるようにしたいです。

発生している問題・エラーメッセージ

ネットで検索した方法だとセル毎にスクリプト作成しないといけない状態で
2000近くあるので現実的に難しいです。
ひとつひとつスクリプトを組まずにまとめて組める方法はありますでしょうか?

該当のソースコード

function showListBox(){ const html = HtmlService.createHtmlOutput(` <div> <select id="list" multiple> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> </select> </div> <div> <button onclick="submit()">決定</button> </div> <script> function submit() { const list = document.getElementById("list"); const arr = []; for ( const item of list ) { if ( item.selected ) { arr.push(item.value); } } google.script.run.setSelectedValues(arr.join(",")); google.script.host.close(); } </script> `); SpreadsheetApp.getUi().showModalDialog(html, "選択してください"); } function setSelectedValues(items){ const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const sheet = spreadsheet.getActiveSheet(); sheet.getRange("'M:M").setValue(items); }

コメントを投稿

0 コメント