I have an Excel s/s which has some simple VBA in the background that I wrote myself. Table inside has about 5000 rows by 6 columns and depending on user selection looks at rank of how often a particular word or character appears - it's a language tool. The macros simply allow the user to increase rank by one each time; reveal answers line by line; or start from beginning (set rank back to 1). Works fine in VBA and quickly too.
However I want to share with Mac people who don't have Excel! I have a working version in Google Sheets with script which also works - programming in script wasn't too difficult to pick up as this was pretty basic and I have VBA background. Example of script below though I don't think that's the issue - probably my understanding of how google script works in general.
Firstly just adjusting the choice of study level taken 15 seconds (that doesn't depend on script) - excel it's about 5sec - there are lots of countifs and rank formula. However in VBA running any of the code takes under 1sec. In script it takes 11 sec. I can't believe the speed differences!
I have made several copies of the s/s so I can play with developing and see what optimises the calculations (not the script - there's not too much to optimise there) - and notice all share the same script - this is alien to me as in VBA the code stays with the s/s. Is this one of the issues?
Why is Google Sheets so slow?
Simple code functions:
function IncreaseRankSelection(){
var spreadsheet = SpreadsheetApp.getActive();
if (spreadsheet.getRange('Q13').getValues()=="Yes"){
spreadsheet.getRange('K3:M67').activate();
spreadsheet.getActiveRangeList
().setFontColor('#ffffff') }
else {
spreadsheet.getRange('K3:M67').activate();
spreadsheet.getActiveRangeList().setFontColor('#999999') }
if (spreadsheet.getRange('Q8').getValues()==spreadsheet.getRange('Q5').getValues()){
Browser.msgBox('There are no more Sets to study!')}
else {
var startvalue = spreadsheet.getRange('Q8').getValues();
var newvalue = (Number(startvalue) + 1);
spreadsheet.getRange('Q8').setValue(newvalue);
};
spreadsheet.getRange('T17').setValue('1');
newvalue2=spreadsheet.getRange('T10').getValues();
spreadsheet.getRange('Q9').setValue(newvalue2);
spreadsheet.getRange('Q8').activate();
};