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 to1
,1
,abc
, andabc
, respectively.
Reference:
- I answered this sample script to this thread on Stackoverflow.