下のようなものを作る。
コード
code.gs
function showDialog(e){
// ⎾A列以外またはCheckBoxがオフ⏌ならば何もしない。
if (e.range.columnStart !== 1 || e.value === 'FALSE') return;
// HTMLを組み立て.
let html = HtmlService.createTemplateFromFile('index');
html.row = e.range.rowStart;
html.col = e.range.columnStart;
html = html.evaluate().setWidth(120).setHeight(140);
SpreadsheetApp.getUi().showModalDialog(html, '入カ値を選択');
}
function inputValues(items, row){
SpreadsheetApp.getActive().getActiveSheet().getRange('C' + row).setValue(items);
}
index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<style>
.box select {
width: 100px;
}
</style>
<body>
<div class="box">
<select id="items" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div>
<button id="inputdata">入カ</button>
</div>
<script>
document.getElementById("inputdata").addEventListener("click", submit);
function submit() {
const items = document.getElementById('items');
const selectedItems = Array.from(items, (item) => [item.selected, item.value] ).filter(e => e[0]).map(e => e[1]);
console.log(selectedItems)
google.script.run.inputValues(selectedItems.join(','),<?= row ?>);
google.script.host.close();
}
</script>
</body>
</html>
トリガーで、「編集時」に「showDialog」が起動するように設定しておくこと。