Auto Hide Columns (or rows) with Make.com API - save 13h+

How to Hide Rows and Columns in Google Sheets Using API


Tired of messy spreadsheets? Let me show you how to programmatically hide columns and rows in Google Sheets.



The Problem


I needed to hide everything except the last 14 columns automatically when generating PDFs. Doing this manually wasn't an option.



The Solution


We'll use Google Sheets API to make an arbitrary call that handles the hiding. Here's how it works:


  • Make API call to sheets
  • Send JSON payload specifying which columns/rows to hide
  • Let Google handle the rest


  • The Code Implementation


    I found this initially as Python code, but converted it to JSON format that the Google Sheets API expects:


    {


        "requests": [


          {


            "updateDimensionProperties": {


              "range": {


                "sheetId": "YOUR_SHEET_ID",


                "dimension": "COLUMNS",


                "startIndex": 43,


                "endIndex": 44


              },


              "properties": {


                "hiddenByUser": true


              },


              "fields": "hiddenByUser"


            }


          }


        ]


      }



    For Rows Instead of Columns


    Simply change "COLUMNS" to "ROWS" in the dimension field. The rest stays the same.



    Advanced Usage


    You can get fancy with this by:


  • Filtering by dates
  • Hiding based on status
  • Hiding specific client data
  • Any other column value condition


  • FAQ


    Q: Will this affect the original data?


  • A: No, it only affects the display. Your data remains intact.

  • Q: Can I unhide using the same method?


  • A: Yes, just set hiddenByUser to false

  • Q: Does this work with multiple sheets?


  • A: Yes, just specify the sheet ID in your request


  • Get The Code


    You can find this solution:


  • On my Gumroad https://adrianmahdian.gumroad.com/l/HideColumnsOrRows
  • Or just copy from this blog post


  • Need Help?


    If you need a custom solution, reach out via email. Happy to help make your spreadsheets more manageable!

    More educational blogs: