Skip to main content
added 10 characters in body
Source Link

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };

function copycells() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('A4').activate();
  spreadsheet.getRange('\'Driver List \'!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('B4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('B4').activate();
  spreadsheet.getRange('\'Driver List \'!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('C4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('C4').activate();
  spreadsheet.getRange('\'Driver List \'!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('M4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('M4').activate();
  spreadsheet.getRange('\'Driver List \'!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };

function copycells() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('A4').activate();
  spreadsheet.getRange('\'Driver List \'!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('B4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('B4').activate();
  spreadsheet.getRange('\'Driver List \'!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('C4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('C4').activate();
  spreadsheet.getRange('\'Driver List \'!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true);
  spreadsheet.getRange('M4').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true);
  spreadsheet.getRange('M4').activate();
  spreadsheet.getRange('\'Driver List \'!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};

I'm new to sheets script. I want to Loop through each row on one sheet  (Driver List) whilewhile copying specific cells of each row to a second sheet  (Driver List2) until an empty row  (last row) is found. I'm able to do one row at a time and just copy the code for the next row but this is clearingclearly not the right way to loop through data. Any help would be greatly appreciated. This is what I have now:

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };

I'm new to sheets script. I want to Loop through each row on one sheet(Driver List) while copying specific cells of each row to a second sheet(Driver List2) until an empty row(last row) is found. I'm able to do one row at a time and just copy the code for the next row but this is clearing not the right way to loop through data. Any help would be greatly appreciated. This is what I have now:

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };

I'm new to sheets script. I want to Loop through each row on one sheet  (Driver List) while copying specific cells of each row to a second sheet  (Driver List2) until an empty row  (last row) is found. I'm able to do one row at a time and just copy the code for the next row but this is clearly not the right way to loop through data. Any help would be greatly appreciated. This is what I have now:

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };

Source Link
user280508
  • 21
  • 1
  • 1
  • 2

Loop through each row on one sheet coping specific cells of each row to a second sheet until an empty row(last row) is found

I'm new to sheets script. I want to Loop through each row on one sheet(Driver List) while copying specific cells of each row to a second sheet(Driver List2) until an empty row(last row) is found. I'm able to do one row at a time and just copy the code for the next row but this is clearing not the right way to loop through data. Any help would be greatly appreciated. This is what I have now:

function copycells() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('A4').activate(); spreadsheet.getRange(''Driver List '!A4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('B4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('B4').activate(); spreadsheet.getRange(''Driver List '!B4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('C4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('C4').activate(); spreadsheet.getRange(''Driver List '!C4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver List '), true); spreadsheet.getRange('M4').activate(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Driver list2'), true); spreadsheet.getRange('M4').activate(); spreadsheet.getRange(''Driver List '!M4').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); };