Home > Back-end >  How to get font size to show up in a cell in Google Sheets
How to get font size to show up in a cell in Google Sheets

Time:08-14

i've been looking everywhere for solution.

I want to create an app script on Google Sheets that creates a custom formula to show what font size text a cell contains.

I found Google has a function "getFontSize", but no luck in getting it to work:

function FONTSIZE(range) {
  return getFontSize(Number)
}

Any help would be appreciated as i am a script app noob!

CodePudding user response:

I believe your goal is as follows.

  • You want to retrieve the font size.
  • From your showing script, you might want to achieve this as a custom function.

In this case, how about the following modification?

Modified script:

function FONTSIZE(range) {
  return SpreadsheetApp.getActiveSheet().getRange(range).getFontSizes();
}
  • In this case, please put a custom function like =FONTSIZE("A1") and =FONTSIZE("A1:C3") in a cell. By this, the font size of the cell "A1" is returned.

Note:

  • When I saw your showing document of the URL, it seems that it is for Google Slides. If you want to use this with Google Spreadsheet, please use getFontSize() and/or getFontSizes().

References:

  • Related