I'm trying to read in a single cell range in a Google Spreadsheet I've been maintaining for about a year now. Today, I've been getting the following error in my logs:
You must select all cells in a merged range to merge or unmerge them.
I don't have any merged cells in that sheet. I've noticed that the Range method also has a "isPartOfMerge()" method. Trying this on the returned Range object raises the same error as before.
var sht_settings = ss.getSheetByName('Settings');
// lots of code in between
var reg_rate = sht_settings.getRange("B9").getValue();
Normally, I would get an integer correlating to the value in the cell, like "20" or "35". Now just getting the reported error.
Update: Discovered the line that is causing the problem. Running the following sequence allows the correct value to be read.
var reg_rate = sht_settings.getRange(9, 2).getValue();
new_sht.getRange("F3:G3").merge().setValue('INVOICE').setFontSize(18).setFontWeight('bold').setHorizontalAlignment('right');
By changing the getRange()
method to refer to a single cell and remove the merge()
method allows it all to work.