Is there a formula function in Google Sheets to count the number of columns in a merge? I could assign a named range to the merge to make it easier….
For instance: see the highlighted merged cells here, gives 13 columns:
google sheetsgoogle-apps-scriptgoogle-sheets-named-ranges
Best Answer
Sure. Use the range object's
getMergedRanges()
method. Note that it returns an array of Ranges, so if testing a single cell, be sure to[0]
-grab the first range returned. Demo with G3 as the cell to test, and getNumColumns() used to detect merge width, per your example. Run it and choose View→Logs to see what it found.