( by Jonny Litten )
Hi all,
I have no knowledge of javascript, but I would like to make a script that will widen/lengthen the active cell when I click a button. If it could also shrink upon clicking the button a second time that would be ideal. Does anyone have any ideas as to how to accomplish this?
Thank you so much,
Jonny
Have a look at the following animated screenshot:
Have a look at the following code:
///////////////////////////////////////
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [ {name:"Widen Cell",functionName:"widenActiveCell"} ];
sheet.addMenu("Script", entries);
};
function widenActiveCell() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cell = sheet.getActiveCell();
if(sheet.getColumnWidth(cell.getColumn()) == 100) {
sheet.setColumnWidth(cell.getColumn(),10);
sheet.setRowHeight(cell.getRow(),10);
}
else {
sheet.setColumnWidth(cell.getColumn(),100);
sheet.setRowHeight(cell.getRow(),100);
}
};
///////////////////////////////////////
put the above code in your script editor, and then you can use it directly in your Google Spreadsheet.
Click on the Menu "Script" (which is created by this script) and then click on "Widen Cell". Then script will check whether the cell is already widen, if yes then it will shrink it or else it will widen it.
And If you are not much familiar with scripts then check out the following link:
http://igoogledrive.blogspot.com/2012/08/how-to-write-script-in-google.html
I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.
I also take up private and confidential projects:
If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html
No comments:
Post a Comment