I have a spreadsheet that takes input of stock symbols. I would like them to always be in ALL CAPS regardless of how they are typed in. This appears to require some scripting
So, anyone know a way to do exactly what the above code does, but not touch the actual formulas inside the cells, only the text that they output?
Consider to make a slight change in the OP approach: rather than capitalize all the cells content for any case, capitalize according the following conditions:
Example:
function onEdit(e) { var range = e.range; var value = range.getValue(); var sheet = range.getSheet(); var sheetName = sheet.getName(); if (sheetName === 'Sheet1' && range.getRow() > 1 && range.getColumn() > 1 && typeof value === 'string') { if(!range.getFormula()) { range.setValue(value.toUpperCase()); } else { if(range.getFormula().substring(0,6).toUpperCase() == '=UPPER') { return; } else { range.setFormula('=UPPER(' + range.getFormula().substring(1) + ')'); } } } }
Notes:
ind
array was not included.typeof e.value
always returns 'string'
, so instead range.getValue();
is used.