I need the macro to take as reference var targetRange =targetSheet.getRange(targetSheet.getLastRow()+1,1); but only from a range of cells, from 1 to 7. because I need to write in front of the data that the macro brings to me when using getLastRow()+1 it takes everything I write in the sheet and continues copying the same information.
i like app script but i need more assistance
A | B | C | D | E | F | G | H | I | J | |
---|---|---|---|---|---|---|---|---|---|---|
1 | COL1 | COL2 | COL3 | COL4 | COL5 | COL6 | COL7 | COL8 | COL9 | COL10 |
2 | 1 | 8 | 1 | 1 | 5 | 2 | 3 | 0 | 0 | 1 |
3 | 10 | 9 | 8 | 2 | 3 | 6 | 5 | 7 | 3 | 6 |
4 | 9 | 8 | 8 | 2 | 8 | 1 | 4 | 4 | 9 | 8 |
function getvaluesfromARangeofCells() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheet1");
const [[a1,,,,,,,,,],[,b2,,,,,,,,],[,,c3,,,,,,],[,,,d4,,,,,]] = sh.getDataRange().getValues();
Logger.log("a1: %s, b2:%s, c3:%s, d4: %s",a1,b2,c3,d4);
}
xecution log
5:06:07 PM Notice Execution started
5:05:58 PM Info a1: COL1, b2:8.0, c3:8.0, d4: 2.0
5:06:10 PM Notice Execution completed