Answer the question
In order to leave comments, you need to log in
Store values of three columns?
Good day, colleagues!
I'm at the stage of mastering scripts in Google sheets. Need help from professionals.
There are three columns of imported data from another table "Month". At some point, the text "September" appears in cell A2, respectively, from the three columns "Month" all values are copied into three columns "September", then at some point the text in cell A2 changes to "October", respectively, all the data is copied as values into three columns "October" and so on...
We need the code of such a script or advice on how this can be written through writing scripts.
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
1) Get the current date, extract the month from there.
2) Get the column numbers for the record
3) Move the data.
function setData(){
/* Боев Григорий (с) 2020 (telegram @ProgrammerForever) */
const FIRST_ROW = 3; // Первая строка
const FIRST_OUT_COL = 10; // Первый столбец, Сентябрь
const FIRST_IN_COL = 7; // Первый столбец с исходными данными
const DATA_WIDTH = 3; // Столбцов с данными
const SHEET_NAME = "Лист1"; // Имя листа
let now = new Date();
let month = now.getMonth();//Либо получаете номер месяца (от 0 до 11) анализируя вашу ячеййку
let sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME);
let inRange = sheet.getRange(FIRST_ROW, FIRST_IN_COL, sheet.getMaxRows(), DATA_WIDTH);
let inData = inRange.getValues();
let outRange = sheet.getRange(FIRST_ROW, FIRST_OUT_COL + month*DATA_WIDTH, inData.length, DATA_WIDTH);
outRange.setValues(inData);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question