Untitled
unknown
plain_text
2 years ago
697 B
1
Indexable
Never
function cellToTitleCase() { function titleCase(str) { let upper = true let newStr = "" for (let i = 0, l = str.length; i < l; i++) { if (str[i] == " ") { upper = true newStr += str[i] continue } newStr += upper ? str[i].toUpperCase() : str[i].toLowerCase() upper = false } return newStr } let spreadsheet = SpreadsheetApp.getActive(); let sheet = spreadsheet.getActiveSheet(); let cellRange = sheet.getActiveCell(); let currentValue = cellRange.getValue() let titleCaseValue = titleCase(currentValue) cellRange.setValue(titleCaseValue) }