First of all, thank you for all your participation, most of my answers are already replied in this stack overflow.
So, I would like to have, in a specific column, for each new form submitted, a specific number (like a tracking number for each form).
I did this code, which is working perfectly to do what i want :
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var row = SpreadsheetApp.getActiveSheet().getLastRow();
sheet.getRange(row,1).setValue(row+10071);
}
But my issue,that is working in all the sheet of my spreadsheet, and I want it only in a specific sheet. So I tried with getSheetByName like this :
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getSheetByName(mysheetname);
var mysheetname="Module2"
var row = SpreadsheetApp.getSheetByName().getLastRow();
sheet.getRange(row,1).setValue(row+10071);
}
But is not working at all.
Sorry for my bad english, but I did my best to be clear. If someone can help me, I will be very grateful. Regards
Paul
Perhaps try adding an IF
to restrict the numbering to only that sheet: if (sheet.getName() = "*your sheet name*")
So, all together it would be:
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var row = SpreadsheetApp.getActiveSheet().getLastRow();
if (sheet.getName() = "*your sheet name*") {
sheet.getRange(row,1).setValue(row+10071);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.