Reputation: 258
I have written script for Google sheets with offset when a forms is submitted. There are 2 sheets with 2 associated Gforms.
Previously, the following script was working well on both sheets. Suddenly, the scripts were working only on one sheet. I have tried to launch manually the script on the active sheet I want (sheet activated obviously), the script is not running. However, the script is well running on the other sheet.
To sum-up:
The script is not running (manually neither with Gforms submission offset): sheetname "DemandeIntervention F-TEC-052"
The script is running (manually or with Gforms submission offset): sheetname "RapportIntervention F-QUA-052"
Hereafter the script:
function CopyFormatting() {
//Déclaration des variables
var SS = SpreadsheetApp.getActiveSheet(); //Sheet of forms response
var LastRow = SS.getLastRow(); //last row of sheet (n)
var RefRow = SS.getRange('3:3'); //Row n°3 considered as reference
//Copy formatting to last row from reference row
RefRow.copyTo(SS.getRange(LastRow,1), {formatOnly: true});
}
Please, could you help me to run the script on both sheets? Thank you
Upvotes: 0
Views: 162
Reputation: 26836
B104
.Thus SS.getLastRow();
retrieves 104
as the last row of the sheet, and consequently cell A104
is the one to be formatted during each script execution.
You can avoid this problem by deleting all rows below the row with the last form response.
If it is very important for you to have text i B104
, then you have to replace getLastRow()
through other methods, such as e.g. getNextDataCell(direction).
Upvotes: 1