T
T
trazer912021-03-11 15:30:14
Google Apps Script
trazer91, 2021-03-11 15:30:14

We need a macro that, when executed, will copy the string and paste its values ​​below into a free string. How to do it?

There is a line with a dynamic date (2:2), on which, in fact, all the data in it depends. It is necessary to keep a history of changing the values ​​​​in this line by creating a log in the form of a list. To do this, when executing the macro, copy the line and paste its values ​​below into a free line, so that a table is created in this way.

The figure shows how it should look like:
1. a string whose values ​​need to be copied;
2. lines that have already been copied before by this method;
3. the first free line where the values ​​will be copied after the macro is executed.

604a0cd10432e727905491.png

I tried to find a formula that could implement this, but I couldn’t, I came to the conclusion that only macros would help in solving my problem, but I’m not strong at writing macros at all, I would be grateful for help or a kick in the right direction.

UPDATE:
I found a solution to my question - a script in Google spreadsheets:

function copytestdata() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
varsheet1 = ss.getSheetByName("original");
var sheet2 = ss.getSheetByName("copy");

sheet1.getRange("A2:H1").copyTo(sheet2.getRange(sheet2.getLastRow()+1,1,1,7), {contentsOnly:true});
}

original and copy - sheet names, replace them with your own, in my case they are the same
A2:H1 - replace with your range,

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
trazer91, 2021-03-11
@trazer91

I found a solution to my question - a script in Google spreadsheets:
function copytestdata() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
varsheet1 = ss.getSheetByName("original");
var sheet2 = ss.getSheetByName("copy");
sheet1.getRange("A2:H1").copyTo(sheet2.getRange(sheet2.getLastRow()+1,1,1,7), {contentsOnly:true});
}
original and copy - sheet names, replace with your own in my case they are the same
A2:H1 - replace with your range that will be copied

A
Alexander, 2021-03-11
@ForestAndGarden

  1. There are no macros in Google Sheets. There are scripts.
  2. It is clear that formulas cannot solve the idea, because they are not invented for this.
  3. Use integration services: IFTTT, Zapier, Integromat, Microsoft Flow etc. You don’t really need to be able to program, but you need to understand the logic of solving the problem clearly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question