I have a spreadsheet for various departments and I am trying to create forms (in spreadsheet form) for each department populating the number of staff in each department and the classes they teach.
I have created a function to copy this data, however, it doesn't stop when it reaches a blank but continues on for the rest of the column. There was a similar question that had been asked, however, that searches the entire column rather than starting at a specific point.
I feel like I am confusing the issue a little so to give an example:
English department data starts at row 3, the staff details are in column H up to row 20.
The the Maths department data starts at row 30, the staff details are up to row 45.
My function needs to pick up English in column A, move to column H count the number of cells until row 20, and copy these values into the form I am setting up.
I have created a function that finds the department name, and a function that loops through all the subjects, I just can't find a way to search up to the first blank cell from row x.
The code I found in another question is from Don Kirkby as follows:
function getFirstEmptyRow() {
var spr = SpreadsheetApp.getActiveSpreadsheet();
var column = spr.getRange('A:A');
var values = column.getValues(); // get all data in one call
var ct = 0;
while ( values[ct][0] != "" ) {
ct++;
}
return (ct);
}
Just to add the function needs to be used in the function below, so copy all values until it hits a blank and paste those values into the form:
function countTargetTeacher(myRowOfTarget) {
var teachRow = targetSheet.getRange(myRowOfTarget, 8).getValues();
var targetTeacherRange = targetSheet.getRange(myRowOfTarget, 8, teachLastRow, 3).getValues();
sheet.insertRowsAfter(teacherRow, teachLastRow);
sheet.getRange(teacherRow + 1, 1, teachLastRow, 3).setValues(targetTeacherRange);
// deleteBlankRows() // https://stackoverflow.com/questions/43522602/filter-data-by-column-k-in-google-script-editor-google-sheets
}
Sorry for the long winded post, any help would be appreciated.
Thanks
Fazila