Skip to content

Instantly share code, notes, and snippets.

@srsandy
Last active September 10, 2022 11:25
Show Gist options
  • Save srsandy/d5edbf187b0c02e7adf55b7dd1163c88 to your computer and use it in GitHub Desktop.
Save srsandy/d5edbf187b0c02e7adf55b7dd1163c88 to your computer and use it in GitHub Desktop.
function myFunction() {
// var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// var activeSheet = activeSpreadsheet.getActiveSheet();
var ss = SpreadsheetApp.getActive();
var allsheets = ss.getSheets();
for(var s in allsheets){
var targetSheet = allsheets[s];
SpreadsheetApp.setActiveSheet(targetSheet);
var lrow = targetSheet.getLastRow();
var lcol = targetSheet.getLastColumn();
for (var i = 1; i <= lrow; i++) {
for (var j = 1; j <= lcol; j++) {
var val = targetSheet.getRange(i, j).getValue();
if ( val != "" && isNaN(val) ) {
var activeCellText = val;
var activeCellTranslation = LanguageApp.translate(activeCellText, 'ja', 'en');
targetSheet.getRange(i, j).setValue(activeCellTranslation);
}
}
}
}
/* var targetSheet = activeSheet;
var lrow = targetSheet.getLastRow();
var lcol = targetSheet.getLastColumn();
for (var i = 1; i <= lrow; i++) {
for (var j = 1; j <= lcol; j++) {
var val = targetSheet.getRange(i, j).getValue();
if ( val != "" && isNaN(val) ) {
var activeCellText = val;
var activeCellTranslation = LanguageApp.translate(activeCellText, 'ja', 'en');
targetSheet.getRange(i, j).setValue(activeCellTranslation);
}
}
} */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment