How about this approach? Make it a simple onEdit trigger and if anything is changed in the sheet, then set them to the right font and size right away.
Here is what the script would look like:
function onEdit(e)
{
var selectedSheets = ["Sheet1","Sheet3","Sheet6"]; // select the sheets you want to run the function for
var sheet = SpreadsheetApp.getActiveSheet();
var row = e.range.getRow();
var col = e.range.getColumn();
var sheetName = sheet.getName();
if ((selectedSheets.includes(sheetName)) && (row > 3))
{
sheet.getRange(row,col).setFontFamily("Arial").setFontSize(8)
};
}
If spreadsheet entry happens from non-manual steps, then onEdit would not work and a timed based change would be ok. Here is how you would do it to force change all fonts on all sheets to the right one you want:
function timeTrig()
{
var selectedSheets = ["Sheet1","Sheet3","Sheet6"]; // select the sheets you want to run the function for
var ss = SpreadsheetApp.getActiveSpreadsheet();
for (var i=0;i<selectedSheets.length;i++)
{
sheet = ss.getSheetByName(selectedSheets[i]);
sheet.getRange(4,1,sheet.getLastRow(),sheet.getLastColumn()).setFontFamily("Arial").setFontSize(8)
};
}
Setup the timeTrig function as a trigger and make it run at whatever frequency you choose. Daily, hourly, etc..
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/469c22f7-d17a-43e8-9d29-cf86148b43f9n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/79011c83-f919-4e0c-a012-346773698d06n%40googlegroups.com.
One other comment on function timeTrig. It expects the listed sheets to be in the spreadsheet and named exactly as in the function (Sheet1, etc..).
If those sheets are not there, it will give you an error as it fails to find that sheet in the spreadsheet. A quick if statement can bypass that error if you want.
Just add (before the setFontStyle line)
If (sheet == null ) {continue;}
This will just skip that sheet if it does not exist in the spreadsheet.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/79011c83-f919-4e0c-a012-346773698d06n%40googlegroups.com.