0

I have a spreadsheet with "Sheet 1" containing barcode values for X number of rows in Column A, as well as a single "Client" name. I am wanting to copy this barcode data range into another sheet ("Sheet 2"), but in a separate column, copy the single cell (Client) for as many rows as there are in the barcode data range.

The idea being that once I clear the data from Sheet 1 for a new client, I can still retain a full log in Sheet 2.

Sheet 1 Sheet 2

I have successfully copied the barcode data range within Apps Script (see below), but cannot figure out how to copy and paste the single cell for the same number of rows.

function copyBarcode() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('Sheet1');
  var targetSheet = ss.getSheetByName('Sheet2');
  
  var barcodeRange = sourceSheet.getRange('A1:A').getValues();
  for(i = 0; i < barcodeRange.length; i++)
  {
    targetSheet.appendRow(barcodeRange[i]);
  }
  
}
Rubén
  • 34,714
  • 9
  • 70
  • 166
Matt
  • 1

0 Answers0