I am trying to find a way to auto increment a number to let the cell value follow. This is what I have for now.
//worksheets
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("QR CODE GENERATOR");
//lastrow
const lastrow_ws = ws.getLastRow();
function createQRCode(){
var startPoint = ws.getRange(2, 2);
var startPoint_value = ws.getRange(2, 2).getValue();
var qrRange = ws.getRange(lastrow_ws, 2);
var i = 3;
if (startPoint_value == ""){
startPoint.setValue('=IMAGE("https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl="&C2)');
} else {
qrRange.setFormula('=IMAGE("https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl="&C' + i + ')');
i++
}
}
For this script, I would simply like it to place a QR Code Generator on a cell each time it is called. The script is called through a trigger onFormSubmit.
If B2 is empty,
Enter =IMAGE("https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl="&E2)
and if B2 is not Empty,
Enter =IMAGE("https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl="&E3)
and so on to E1000 etc.
I was thinking a For Loop might be the answer but I have no idea how to implement it in this situation. I have a done a similar thing using ForEach but I can't apply it in this situation.
Screenshots of desired output: