How to create a Data Entry form in Google Sheets

When it comes to mass data entry works, it is very essential to use data entry forms in order to improve accuracy and speed. If you use google sheets there are are many advantages compared to data entry forms like in MS Access which are installed on your local computer. The default form option comes with the Google sheet (Google Form) is not suitable for mass data entry works. Instead of that, you can use Google Apps-Scripts to build a data entry form in Google Sheet itself or build web apps.

In this post, I will show you how to create a data entry form in Google Sheet itself to use for mass data entry works.

In the previous post, I explained, “How to Create a Dependent Drop-Down List in Google Sheet“. Here I am going to use those two fields as part of the data entry form.

Creating the form interface

You can simply create the form interface by taking the cells as input fields. The following form includes six input fields namely “Region”, “Country”, “Population” “GDP”, “Area”, and “Literacy” in D4, D6, D10, D12, G10, and G12 cells respectively.

Figure 01: Data entry form

You can protect the entire sheet except the input fields to prevent users from editing the other cells.

The save button

Here I am using an image as the save button. (Later I will assign apps script function to this image to copy the data into another sheet once you clicked it).

To create this image go to, Insert > Drawing and then draw a rounded rectangle using the Rounded Rectangle shape tool. Then add your text and add colors using color tools.

Apps script to copy data from the form to another sheet

Once you click the save button, the data in the input field should copy to another sheet. This task can be achieved through Google Apps Scripts.

To access Script Editor, go to Tools > Script editor. Give a name to your project. Then copy the following script to the script editor and save.

Rename your sheet which includes the form as “Form” and another sheet as “Data”. We are going to copy the data in the Form to this “Data” sheet.

function submitData() {
  var ss        = SpreadsheetApp.getActiveSpreadsheet();
  var formSS    = ss.getSheetByName("Form"); //Form Sheet
  var datasheet = ss.getSheetByName("Data"); //Data Sheet
  
  //Input Values
  var values = [[formSS.getRange("D4").getValue(),
                 formSS.getRange("D6").getValue(),
                 formSS.getRange("D10").getValue(),
                 formSS.getRange("G10").getValue(),
                 formSS.getRange("D12").getValue(),
                 formSS.getRange("G12").getValue()]];
  
  datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 6).setValues(values);
}

Assign Apps Script to save button

Now you can assign the function submitData() to the save button (actually the image). To do that, click on the image and then click the menu icon in the top right corner of the image. Then select the “Assign script” option. In the text box type your function name, submitData and click OK.

Now you can fill the form and copy the data to the “Data” sheet by clicking the save button.

Make a copy of the above Google Sheet

Go to Tools > Script editor to view the code

What next?

The above code does not clear the input fields after submitting the data. You can use clear() function to clear the required fields after submitting the data to the “Data” sheet.

The data validation part is another essential part in data entry forms. You can check the values of the field before they copying to the “Data” sheet using conditional statements. Then you can provide meaningful error messages to the user using Browser.msgBox("Error message!")function.

Even though this method is better for mass data entry works than Google Forms, there are a number of other issues. You have to grant edit permission to the user to the “Data” in order to copy the form data to it. Therefore some errors can happen during the data entry. The form is also not much user-friendly.

In order to overcome those issues, you can build your own web app using Google Apps Script HTML Service.

If you wish to create a more advanced data entry form you may read; How to Create Data Entry Form with Google HTML Service and Submit Data to Google Sheets.

32 thoughts on “How to create a Data Entry form in Google Sheets”

  1. Thank you for this. However, I encounter a problem. After saving the data, it goes to the last row (A1000). How to fix it? Many thanks!

    Reply
  2. Works well. But all my items are lined up horizontally. what if I would like several Items with item code and quantity to line up vertically and will return the same customer name, date of purchase order and other several detail. I am making data entry for purchase orders. would appreciate if you could help with the script.

    Reply
  3. Is there a way to email the form to another person? We would like one department to receive the data on the form -because it’s clear and concise to read off of, and the other department would keep the data they entered on form for their records.

    Reply
    • Yes, you can.
      Replace line 4 (“dataSheet” variable) with the following.

      var ssData = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1AhWYCSWz7ZW5JvGZ9VBCwgSRoc9v4MWXmbYQh0ZvpBc/edit#gid=0"); //Add your Spreadsheet URL here
      var datasheet = ssData.getSheetByName("Data"); //Data Sheet

      You also need to authorize to run the code in your google account.

      Reply
  4. This is great, thank you. I’m trying to figure out a way of including a timestamp every time data is entered. Do you have any suggestions. Many thanks.

    Reply
    • You can add new Date()
      Example:

      var values = [[formSS.getRange("D4").getValue(),
      formSS.getRange("D6").getValue(),
      formSS.getRange("D10").getValue(),
      formSS.getRange("G10").getValue(),
      formSS.getRange("D12").getValue(),
      formSS.getRange("G12").getValue(),//Add a ","
      new Date()]]; //Add new Date() function

      datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 7).setValues(values); //Increase number of columns by one (Eg. 6 to 7)

      Reply
  5. Thank you very much very useful. I am trying to build a form that has some dynamic content. That is users after a service will have to fill up products they have used so these product lines will be an exit from product inventory. It can be from one to ten lines so I need to use some kind of dynamic range. Any idea how this can be done? Thank you very Much

    Reply
  6. Is it possible with the suggestion made earlier of sending this data to a different spreadsheet that I could have the data associate itself to its corresponding Sheet within the spreadsheet? For example each time ID: 1 is selected in the form all the data entered would go into the Sheet labeled 1 and so on?

    Thank so much for your help it has been invaluable

    Reply
  7. Hi,

    How can you add an alert popup when the data is submitted? Also, It would be of great help if you can show how to use the Clear data option once the form is submitted.

    Reply
  8. can i have a drop down list in the data entry. to tell whether to save all the entries in data(sheet) or data2(sheet2). Its like having 2 datasheet.thanks a lot inadvance

    Reply
    • Assuming your sheet name dropdown is in the “G4” cell.

      function submitData() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var formSS = ss.getSheetByName("Form"); //Form Sheet
      var datasheet = ss.getSheetByName(formSS.getRange("G4").getValue()); //Data Sheet

      //Input Values
      var values = [[formSS.getRange("D4").getValue(),
      formSS.getRange("D6").getValue(),
      formSS.getRange("D10").getValue(),
      formSS.getRange("G10").getValue(),
      formSS.getRange("D12").getValue(),
      formSS.getRange("G12").getValue()]];

      datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 6).setValues(values);
      }

      Sheet with the modified code. Make a Copy to your drive.
      https://docs.google.com/spreadsheets/d/1Y1V3qfSqmhV4q7yZrvvaA0snJ9Ip98u_miGm7j6mfMk/edit?usp=sharing

      Reply
  9. Here’s what i added to clear after clicking the submit button. I didn’t study coding and just did it by trial and error.

    function submitData() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var formSS = ss.getSheetByName(“Form”); //Form Sheet
    var datasheet = ss.getSheetByName(“Data”); //Data Sheet

    //Input Values
    var values = [[formSS.getRange(“B6”).getValue(),
    formSS.getRange(“B7”).getValue(),
    formSS.getRange(“B8”).getValue(),
    formSS.getRange(“B9”).getValue(),
    formSS.getRange(“B10”).getValue(),
    formSS.getRange(“B11”).getValue(),
    formSS.getRange(“B12”).getValue()]];

    datasheet.getRange(datasheet.getLastRow()+1, 1, 1, 7).setValues(values);

    formSS.getRange(“B7”).clear()
    formSS.getRange(“B8”).clear()
    formSS.getRange(“B9”).clear()
    formSS.getRange(“B10”).clear()
    formSS.getRange(“B11”).clear()
    formSS.getRange(“B12”).clear()
    }

    Reply
  10. Hi! this is very helpful, is there a way I can get it so that the data is added to next available row rather than the last row, as it is sending the data to row 500 etc at the bottom of my spreadsheet.

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.