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);
};