Removing Quote Prefix of Cell value using Google Apps Script (Single Quote)

Gists

In Google Spreadsheet, when a single quote is added to the top letter of the cell value, the cell is used as the text value. About detecting this, I have already reported in this post in my blog. In this post, I would like to introduce a sample script for removing the single quote at the top character of the cell value.

Sample script:

function sample() {
  const sheetName = "Sheet1"; // Please set your sheet name.

  const range = SpreadsheetApp.getActiveSpreadsheet()
    .getSheetByName(sheetName)
    .getDataRange();
  range
    .createTextFinder("^'{1,}")
    .useRegularExpression(true)
    .replaceAllWith("");
  range.setValues(range.getValues());
}
  • In this script, for example, '001, '''001, 'abc, and '''abc are converted to 1, 1, abc, and abc, respectively.

Reference:

 Share!