Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:39:37+00:00 2026-06-15T02:39:37+00:00

In my google spreadsheet A, I use a combination of the TRANSPOSE and IMPORTRANGE

  • 0

In my google spreadsheet A, I use a combination of the TRANSPOSE and IMPORTRANGE formulas to import data from calendar spreadsheet B, in order to fill out a working schedule for events. Because on each date there are 3 event slots, which are not always filled, I am getting a lot of obsolete columns.

Table layout:

row1:  01-01-2013  01-01-2013  01-01-2013  02-01-2013
row2:  Event_ID    Event_ID    Event_ID    Event_ID
row3:  Event_name  Event_name  Event_name  Event_name

Rows 1 and 2 contain auto-generated dates and event_ID’s so these are never empty. Cell nr. 3 displays empty when there was no event added to that slot, but in fact there is a CONTINUE-formula in there to continue the importrange-formula from cell A1.

I´m looking for a script to automatically hide the colums in which cell nr. 3 doesn’t contain imported data.

Not understanding a thing about JavaScript (but willing to learn), I have tried to combine pieces from existing scripts but at this point I cannot manage to make any sense of these codes…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:39:38+00:00Added an answer on June 15, 2026 at 2:39 am

    The following code does the trick:

    function onOpen() {
      // get active spreadsheet
      var ss = SpreadsheetApp.getActiveSpreadsheet();
    
      // create menu
      var menu = [{name: "Hide columns", functionName: "hideColumn"},
        {name: "Show all columns", functionName: "showColumn"}];
    
      // add to menu
      ss.addMenu("Check", menu);
    }
    
    function hideColumn() {
      // get active spreadsheet
      var ss = SpreadsheetApp.getActiveSpreadsheet();
    
      // get first sheet
      var sheet = ss.getSheets()[0];
    
      // get data
      var data = sheet.getDataRange();
    
      // get number of columns
      var lastCol = data.getLastColumn()+1;
    
      Logger.log(lastCol);
    
      // itterate through columns
      for(var i=1; i<lastCol; i++) {
         if(data.getCell(3, i).getValue() == '') {
            sheet.hideColumns(i);
         }
      }
    }
    
    function showColumn() {
      // get active spreadsheet
      var ss = SpreadsheetApp.getActiveSpreadsheet();
    
      // get first sheet
      var sheet = ss.getSheets()[0];
    
      // get data
      var data = sheet.getDataRange();
    
      // get number of columns
      var lastCol = data.getLastColumn();
    
      // show all columns
      sheet.showColumns(1, lastCol);
    }
    
    1. Creates menu upon opening file
    2. First menu option, hides all columns with row 3 being empty
    3. Second option, shows all hidden columns

    See example file I prepared to watch it in action: Hide columns based on cell value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to use Google Api for accessing/editing Google SpreadSheet.
I have the following data being generated from a google spreadsheet rss feed. いきます,go,5
I'm grabbing data from a published google spreadsheet, and all I want is the
I found this wonderful example of pulling data from a Google spreadsheet in JSON:
I am trying to get data from a Google Doc Spreadsheet, using javascript and
I'm trying to use access the google spreadsheet's solver feature from google-apps-script. Does anyone
I'm learning how to use the Google spreadsheet API to get info from a
I'm trying to summarize data from several Google spreadsheet' sheets in a single one
Using Google Apps Script, I've made a UI for use on a Google Spreadsheet.
Is there a JavaScript-only, direct method to read information from a Google Spreadsheet and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.