Rotate text vertically in Google Spreadsheet using Google Apps Script

So you are using the Google Spreadsheet and you need to rotate the text in any cell or range of cells vertically. There is no options to rotate the text orientation. Some forum suggested us to add a formula in each cell such as =ARRAYFORMULA(CONCATENATE((MID( "TEXT TO DISPLAY"; ROW(INDIRECT("YY1:YY"&LEN( "TEXT TO DISPLAY" ))); 1)&CHAR(10)))).

If you to write a script for this purpose, click Tools > Script Editor. Copy and paste the following code:
function verticalText() {
  
  var results = SpreadsheetApp.getActiveRange();
  
  var values = results.getValues();
  var values1 = results.getValues();
  var formulas = results.getFormulasR1C1();
  
  for (var i in formulas) {
    for (var j in formulas[i]) {
     values1[i][j] = '=ARRAYFORMULA(CONCATENATE((MID( "' + values[i][j] + '"; ROW(INDIRECT("YY1:YY"&LEN( "' + values[i][j] + '" ))); 1)&CHAR(10))))';
     }
  }
  results.setFormulasR1C1(values1);
};



function onOpen() {
  SpreadsheetApp.getActiveSpreadsheet().addMenu(
    "Rotate Text",
    [
      { name: "Rotate text vertically", functionName: "verticalText" }      
    ]
  );
}

Save the script with any name and close the script file. Now refresh your spreadsheet and oops there you will get an option called Rotate Text, next to Help menu. Select a range of cells and click Rotate text vertically and it will be rotate yout text orientation. Remember you have to add script for each of your individual Google Spreadsheet.