Reputation: 125
I´d like to know how i convert my entire spreadsheet to uppercase, on every load
I did it onEdit, but only the cell i edit
function onEdit(e) {
if (typeof e.value != 'object') {
e.range.setValue(e.value.toUpperCase());
}
}
Thanks!!
Upvotes: 1
Views: 719
Reputation: 1908
function ScriptOnLoad()
{
var spreadsheet = SpreadsheetApp.getActive();
var mysheet=spreadsheet.getActiveSheet();
if (mysheet.getSheetName()!='SheetB') return;
var rowCount=mysheet.getLastRow();
var colCount=mysheet.getLastColumn();
for (row=1; row<rowCount+1;row++)
{
for (col=1; col<colCount+1;col++)
{
var myFormula=mysheet.getRange(row, col).getFormula();
if (myFormula!="")
{
//Make as comment if formula will let as is
mysheet.getRange(row, col).setFormula( myFormula.toUpperCase() );
}
else
{
var myFormula=mysheet.getRange(row, col).getValue();
try
{
mysheet.getRange(row, col).setValue( myFormula.toUpperCase() );
}
catch(err)
{
}
}
}
}
}
Upvotes: 0
Reputation: 201438
If my understanding is correct, how about this sample script? Please think of this as just one of several answers.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
sheets.forEach(function(sheet) {
var range = sheet.getDataRange();
var values = range.getValues().map(function(row) {return row.map(function(col) {return typeof col == "string" ? col.toUpperCase() : col})});
range.setValues(values);
});
}
onOpen()
is run by the OnOpen event trigger.onOpen()
with the script editor.If you want to convert the values in the specific sheet, how about the following script?
function onOpen() {
var sheetName = "###"; // Please set the sheet name here.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
var range = sheet.getDataRange();
var values = range.getValues().map(function(row) {return row.map(function(col) {return typeof col == "string" ? col.toUpperCase() : col})});
range.setValues(values);
}
If I misunderstood your question and this was not the direction you want, I apologize.
Upvotes: 2