I'm using this script to automate ImportXML with a trigger in Google Sheets. It works perfectly for 1 URL cell reference (B2 in this ex) and returns the result in D2
function getData() {
var queryString = Math.random();
var cellFunction1 = '=IMPORTXML("' + SpreadsheetApp.getActiveSheet().getRange('B2').getValue() + '?' + queryString + '","'+ SpreadsheetApp.getActiveSheet().getRange('A3').getValue() + '")';
SpreadsheetApp.getActiveSheet().getRange('D2').setValue(cellFunction1);
}
I need it to loop and return the result for all cells in the "B:B" range (ideally none empty ones only) and post the result in the corresponding cell in the "D:D" range.
Is it possible, or will I have to resort to writing the script for each row I want data from?