Home > other >  How can I copy the entire row using App Scrpts in Google Sheets
How can I copy the entire row using App Scrpts in Google Sheets

Time:11-24

I have a spreadsheet on Google Sheets with two tabs (Tab1 and Tab2).

Aba1 has several lines.

How can I copy the entire row of the cell that is selected in Tab1 to the second row of Tab2?

I would like an App Scripts script to do this.

CodePudding user response:

const values = SpreadsheetApp.getActiveRange().getActiveRange().getValues();
const sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Tab2');
sheetTo.getRange(2, 1, 1, values[0].length).setValues(values);

Reference:

getActiveRange()

  • Related