![見出し画像](https://assets.st-note.com/production/uploads/images/119104921/rectangle_large_type_2_f17de9f267e9b067af67dd70f6250104.png?width=1200)
Photo by
shiekasai
毎月、日別のタブ作ってくれる人
毎月、日別のタブを作ってくれる人がいる。
あれ意外と大変だと思ってる。
それも一つじゃないのよね。各部署でいろんな日別のタブ作ってるのよね。
(右クリック→コピー→名前の変更)が20秒だとして
30秒×30日=10分/月
それが10部署あるとして
10分/月×10部署=100分/月=20時間/年の削減できますね。
そこで、chatGPTにお願いしました。
chatGPT、抱きしめたくなるほど優秀。
![](https://assets.st-note.com/img/1697495819417-zhztsSaYAC.png?width=1200)
ちょっと現場寄りに改造。(何なら改造分もchatGPTにお願いした)
function createMonthlyTabs() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var monthNames = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
var currentDate = new Date();
var year = currentDate.getFullYear();
var currentMonth = currentDate.getMonth();
// Get the ORGN sheet
var orgnSheet = spreadsheet.getSheetByName("ORGN");
if (!orgnSheet) {
SpreadsheetApp.getUi().alert("Sheet named 'ORGN' not found.");
return;
}
for (var day = 1; day <= getDaysInMonth(currentMonth, year); day++) {
var sheetName = monthNames[currentMonth] + day;
var newSheet = spreadsheet.insertSheet(sheetName);
// Copy the contents from ORGN sheet
orgnSheet.copyTo(newSheet);
}
}
function getDaysInMonth(month, year) {
return new Date(year, month + 1, 0).getDate();
}
ちなみにBardにお願いしたら、
お願いした通りには返ってこず。
(伝えられなかった私の日本語力がまずい)
(自分で修正すればいいだけの話)
![](https://assets.st-note.com/img/1697496047978-afSsQonPXs.png?width=1200)
本日の勝負、chatGPTの勝ちです。