S
S
Stanislav Maslakov2018-12-14 21:05:21
Google Sheets
Stanislav Maslakov, 2018-12-14 21:05:21

How to write a macro that adds data from another sheet to the end of a range with data?

There is a customer database. Name, Phone, Email, etc.
It is necessary to make a macro that will copy all this data in one sheet and add them to another sheet below all previous data.
How to write this script correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksei Shebanits, 2021-01-29
@shebanits

1. Get a range with data.
2. On the sheet to which you are copying, check the last completed line.
3. Copy your range.

function copyTo() {
  let ss = SpreadsheetApp.getActiveSpreadsheet();
  let sheet1 = ss.getSheetByName("Лист1");
  let sheet2 = ss.getSheetByName("Лист2");
  let data = sheet2.getRange(1, 1, 3, 1).getValues();
  sheet1.getRange(sheet2.getLastRow() + 1, 1, 3, 1).setValues(data);
}

6013d93c94a41198181754.png6013d9412b68d424024249.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question