특정 위치의 열을 주기적으로 복사해서 붙여넣어야 하는 작업이 필요했다. 이를 chatGPT에게 물어보았다.
Make google spreadsheet Apps script code
this is how i want to made it.
- 1/ "insert 1 column left" at "I" column.
- 2/ copy "J" column to "I" column.
답변은 수정할 것 없이 정말 훌륭하게 작성해주었다.
function insertColumnAndCopy() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Step 1: Insert a column at I column
sheet.insertColumnBefore(9);
// Step 2: Copy J column to I column
var rangeToCopy = sheet.getRange("J1:J" + sheet.getLastRow());
var destinationRange = sheet.getRange("I1:I" + sheet.getLastRow());
rangeToCopy.copyTo(destinationRange);
}
잘봤습니다.