Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Width of a merged cell that adjusts with column size and font size changes

$
0
0

I would like to pad the text in a spread sheet cell to fit the current width of the celle.g. in the sample below I would like to adjust the number of hyphens either side of the title text to fill the width of the cell, and to automatically adjust if the column width is changed,

example of text to be padded

In the example Signal Scores is in a merged cell covering the three data columns.

Col A shows the formula in Col B

I have created a named function FMTCELLHDR which does the padding:

 =let(w,(width-LEN(text))/2 -2, concatenate("<",rept("-",w)," ",text," ",rept("-",w),">"))

My problem is determining the Current width of the merged cell:

  • cell("width",ref) does not update when column is resized
  • cell("width",ref) is based on default font 0 and even for single cell is short of full width (2nd line of example)
  • for merged cell cell("width",ref) only returns width of first column, summing widths would be significantly shorter than actual
  • Using a manually specified width works but does not adjust automaticaly for changes in column widths.

Is there a way of more accurately calculating the visible width of a merged cell that adjusts with column size and font size changes?

Either buitin functions or apps script


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>