I have a Google spreadsheet with my monthly balance sheet for my company. I keep track of estimated and actual like this:

Expense | Jan11 Actual | Jan11 Estimate | Dec10 Actual | Dec10 Estimate | etc...

I would love it if I could easily hide all the Estimate columns with a touch of a button, and turn them on with another touch.

How can I do this?


Google Apps Script can do it.

This should get you started:

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [ {name: "Hide", functionName: "myFunction"} ];
  ss.addMenu("Scripts", menuEntries);

function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var colCount = sheet.getMaxColumns();
  var x;
  for ( x = 1; x < colCount; x = x + 2) {
    var r = sheet.getRange(1,x);
  • did this really work? – Open the way Nov 1 '15 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.