Auto Format Google Sheets With Google Forms Input
Google Sheets, Automation

Auto-Format Google Sheets with Google Forms Input

Master Google Sheets Automation by seamlessly integrating Google Forms. Keep your data perfectly formatted with our script-driven guide

Imagine you’ve set up a Google Sheet that integrates seamlessly with Google Forms. This sheet is the nerve center for your customer data inputs, automatically feeding in responses.

But there’s a snag – each new form entry messes up your meticulously crafted cell and row formats.

Sound familiar?

Well, you’re not alone. This is a common headache for many, but fret not, as we dive into a solution that ensures your Sheet’s formatting stays intact.

Understanding the Problem: Format Disruption

When data from Google Forms enters your ‘Form Responses 1’ sheet, it tends to play havoc with your formatting.

Whether it’s the cell layout, font styles, or the entire row structure, the seamless data entry comes at the cost of visual consistency and functionality.

This scenario calls for a robust solution to preserve your Sheet’s aesthetics and usability.

Exploring Solutions: The Paths We Could Take

Several solutions come to mind. One is to constantly reformat cells or rows manually – a tedious and impractical task.

Another is creating a new, pre-formatted sheet and automatically transferring form inputs there.

However, for this article, we’ll focus on a direct, script-based auto reformatting method, applying changes right in the ‘Form Responses 1‘ sheet.

The Chosen Solution: Auto Reformat with Google Scripts

To address our formatting woes, we’ll use Google Apps Script, a powerful tool allowing us to automate tasks within Google Sheets.

Our strategy involves creating a new sheet, ‘Formatted Sheets‘, to serve as our formatting template.

Specifically, we’ll use its second row as our format reference (not a cell).

If you want to set only cells, then the script needs to be customized

Step 1: Setting the Stage with ‘Formatted Sheets’

  • Start by setting up your ‘Formatted Sheets‘ with the desired formatting in its second row
  • This format will act as a blueprint for every new entry in your ‘Form Responses 1‘ sheet

Step 2: Navigating to Apps Script

  • In your ‘Form Responses 1‘ sheet, go to Extensions ⇒ Apps Script
  • Here, you’ll enter the magic – the script that will automate the formatting process

Step 3: Implementing the Script

  • Open the Apps Script editor from your ‘Form Responses 1’ sheet and paste the script below into the Apps Script field
/**
 * The onFormSubmit function is automatically called when a new response is submitted via Google Forms.
 * This function copies the format from a specified row in the "Formatted Sheet" and 
 * applies it to a new row in the "Form Responses 1" sheet filled by the Form response.
 * 
 * The copied format includes cell properties such as font, color, background, and row height.
 * As such, ensuring that all new entries have a consistent format
 * with the predetermined template.
 *
 * Note: Ensure that the "Formatted Sheet" has a row with the desired format
 * which will be used as a template to copy.
 * 
 * Trigger: This function should be set to be triggered by the 'On form submit' event.
 */

function onFormSubmit(e) {
  if (!e) {
    // Event object does not exist, function may be run manually or in debugger
    Logger.log("Function should be triggered by form submission.");
    return;
  }

  // Get spreadsheet object
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  
  // Get the 'Form Responses 1' and 'Formatted Sheet'
  var responseSheet = spreadsheet.getSheetByName("Form Responses 1");
  var formattedSheet = spreadsheet.getSheetByName("Formatted Sheet");
  if (!responseSheet || !formattedSheet) {
    Logger.log("One of the sheets not found.");
    return;
  }

  // Determine the row just filled by the form
  var formResponseRow = e.range.getRow();

  // Determine the range from where format will be copied
  var sourceRange = formattedSheet.getRange(2, 1, 1, formattedSheet.getLastColumn());
  var targetRange = responseSheet.getRange(formResponseRow, 1, 1, responseSheet.getLastColumn());

  // Copy format from the source row to the target row
  sourceRange.copyTo(targetRange, SpreadsheetApp.CopyPasteType.PASTE_FORMAT, false);
}
  • Click Save button

This script will trigger every time a new form response comes in, applying the predefined format from ‘Formatted Sheets‘ to the new entry in ‘Form Responses 1

Step 4: Setting the Trigger

  • Click on the clock icon in the toolbar or navigate to Edit ⇒ Triggers
  • Choose the ‘+ Add Trigger‘ option in the bottom right corner
  • From the dropdown for ‘Choose which function to run‘, select your function, typically ‘onFormSubmit
  • For ‘Choose which deployment should run’, leave it set to ‘Head
  • Under ‘Select event source’, pick ‘From spreadsheet
  • For ‘Select event type’, choose ‘On form submit
  • Configure failure notifications by clicking ‘+‘, to alert you in case the script fails to run
  • Click ‘Save‘ to set the trigger

Step 5: Save and Test

  • After saving the trigger, test it by submitting a response through your Google Form
  • Check ‘Form Responses 1‘ sheet to ensure the new entry matches the format from ‘Formatted Sheets
  • If the format is not applied, check the script and trigger settings for any issues and adjust as needed
  • Once confirmed working, your form responses will now maintain consistency with automatic formatting

Workflow Overview: A Smooth Operational Dance

  1. A user fills out your Google Form
  2. The form response feeds into your ‘Form Responses 1‘ sheet, disrupting the format
  3. The script triggers, pulling the correct format from ‘Formatted Sheets
  4. Your ‘Form Responses 1‘ sheet magically reflects the right formatting, maintaining consistency and order
  5. The script will repeat itself

Conclusion: Effortless Automation

With this setup, every new entry in your Google Sheets will automatically mirror the formatting standards you’ve set, eliminating the need for constant manual adjustments.

This approach not only saves time but also ensures data consistency, crucial for any data-driven task.

Final Thoughts: Beyond Formatting and Further Possibilities

While the method we’ve outlined provides a streamlined way to maintain formatting consistency, it’s just the tip of the iceberg when it comes to what you can achieve with Google Sheets and Google Forms automation.

For instance, rather than updating just one row, you could take the approach of refreshing an entire sheet based on the formatted template.

This is a bit like giving your data a brand-new home that’s already furnished exactly as you need it.

Every time new data comes in, it’s as if you’re moving it into a pristine space that’s preset to your specifications.

Another avenue is creating a completely new sheet for each form submission, serving as a ‘landing pad’ for your data.

This could be especially handy if each dataset requires a distinct separation or if you’re handling a high volume of form entries that need individual attention.

Beyond these, the scripting capabilities in Google Apps Script open doors to even more intricate workflows.

For example, you could automate data validations, generate custom reports, send notifications based on form submissions, and much more.

Create & Scheduling Automatic System Restore on Windows

Automation in Google Workspace is all about crafting a process that fits like a glove to your operational needs.

So feel free to get creative, explore the capabilities of Google Apps Script, and tailor your solutions to the unique rhythms of your data management dance.

With every script and trigger, you’re not just preserving format – you’re choreographing a seamless ballet of data that performs exactly as you direct it.

Leave a Reply

Your email address will not be published. Required fields are marked *