Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of “ScreenUpdating” in Google Apps Script (equivalent VBA-GAS )

I'm looking for the equivalent VBA-GAS of:

Application.ScreenUpdating = False

I'm running a very long macro in one of my Google Spreadsheets and it takes at least 30 seconds to finish it every time. It would be helpful if the macro didn't refresh the screen after every line of code.

like image 311
Frank Montemorano Avatar asked Jul 19 '13 15:07

Frank Montemorano


2 Answers

There isnt. However you should batch all setValues into range writes (ideally a single range write) which will help here.
Only call SpreadsheetApp.flush() at the very end.

like image 138
Zig Mandel Avatar answered Sep 20 '22 20:09

Zig Mandel


I ended up creating a second sheet called 'Start' which just had A1='Please wait...'. The sheet I display all my data on is called 'Report'

Then used:

//Hide Report sheet
SpreadsheetApp.getActive().getSheetByName("Start").showSheet();
var sheet = SpreadsheetApp.getActive().getSheetByName("Report");
sheet.hideSheet();

//Code to update sheet here
sheet.appendRow('Blah','Blah','Blah');

//Show Report sheet
sheet.showSheet();
SpreadsheetApp.getActive().setActiveSheet(sheet);
SpreadsheetApp.getActive().getSheetByName("Start").hideSheet();
like image 39
FrinkTheBrave Avatar answered Sep 21 '22 20:09

FrinkTheBrave