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 8465149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:57:34+00:00 2026-06-10T14:57:34+00:00

I have a google form which populates a google spreadsheet (source sheet). I located

  • 0

I have a google form which populates a google spreadsheet (source sheet). I located and customized a script to pull certain columns -in their entirety- from the source sheet into a new tab/sheet. Apparently there has to be the same number of rows in both sheets for the script to run properly. If not, it turns back an error. Every time a new form is submitted, a row is added to the source sheet, putting the two sheets out of sync and breaking the script.

I’d like help figuring out what function I need to add to the existing script (or what changes I can make to it) so when a new row appears in the source sheet (because a form has been submitted), a blank row appears in the target sheet.

Do I need to tweak my script or add a new function?

function importFunction(a) {
  var ss = SpreadsheetApp.openById("0ApTaY3v27-UqdElwZTBvanNpaC1UckpxaTJRZS1XNWc");
  var sourceSheet = ss.getSheets()[0];
  var ss2 = SpreadsheetApp.openById("0ApTaY3v27-UqdElwZTBvanNpaC1UckpxaTJRZS1XNWc");
  var targetSheet = ss2.getSheets()[1];
  var values1 = sourceSheet.setActiveSelection("C:C").getValues();
  var values2 = sourceSheet.setActiveSelection("AD:AD").getValues();
  var values3 = sourceSheet.setActiveSelection("D:E").getValues();
  var values4 = sourceSheet.setActiveSelection("AE:AE").getValues();
  var values5 = sourceSheet.setActiveSelection("F:H").getValues();
  var values6 = sourceSheet.setActiveSelection("N:U").getValues();
  targetSheet.setActiveSelection("A:A").setValues(values1);
  targetSheet.setActiveSelection("B:B").setValues(values2);
  targetSheet.setActiveSelection("C:D").setValues(values3);
  targetSheet.setActiveSelection("E:E").setValues(values4);
  targetSheet.setActiveSelection("F:H").setValues(values5);
  targetSheet.setActiveSelection("I:P").setValues(values6);
}

Per the suggestion below, I tried to change script to the following, but I get an error – Cannot find method appendRow(). How do I fix that?

    function importFunction(a) {
      var ss = SpreadsheetApp.openById("0ApTaY3v27-UqdElwZTBvanNpaC1UckpxaTJRZS1XNWc");
      var sourceSheet = ss.getSheets()[0];
      var ss2 = SpreadsheetApp.openById("0ApTaY3v27-UqdElwZTBvanNpaC1UckpxaTJRZS1XNWc");
      var targetSheet = ss2.getSheets()[1];
      var targetMax = targetSheet.getMaxRows();
      var values1 = sourceSheet.setActiveSelection("C:C").getValues();
      var values2 = sourceSheet.setActiveSelection("AD:AD").getValues();
      var values3 = sourceSheet.setActiveSelection("D:E").getValues();
      var values4 = sourceSheet.setActiveSelection("AE:AE").getValues();
      var values5 = sourceSheet.setActiveSelection("F:H").getValues();
      var values6 = sourceSheet.setActiveSelection("N:U").getValues();
      if(targetMax == values1.length) {
        targetSheet.setActiveSelection("A:A").setValues(values1);
        targetSheet.setActiveSelection("B:B").setValues(values2);
        targetSheet.setActiveSelection("C:D").setValues(values3);
        targetSheet.setActiveSelection("E:E").setValues(values4);
        targetSheet.setActiveSelection("F:H").setValues(values5);
        targetSheet.setActiveSelection("I:P").setValues(values6);
      }
      else
        targetSheet.appendRow();
    }
  • 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-10T14:57:36+00:00Added an answer on June 10, 2026 at 2:57 pm

    You could simply check the number of available rows in sheet SS2 before writing the values using getMaxRows() and compare it to the length of your data arrays value1.length, then, depending on this comparison add the rows you need using appendRow() eventually in a for next loop.

    EDIT : following your EDIT, I tested a bit further and it appears that appendRow() doesn’t work as I thought, it appends Rows at the begining of an empty sheet… so I tried this :

      if(targetMax < values1.length) {
      var RowsToAdd = values1.length-targetMax
      for(nn=0;nn<RowsToAdd;++nn){targetSheet.insertRowAfter(targetMax)}
      }
    

    Just place it right after var value6=...

    sorry for this little error 😉

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

Sidebar

Related Questions

I have a form which is built dynamically using this jQuery plugin http://code.google.com/p/jquery-dynamic-form/ When
I have a button in a form which constructs a base google search url
We have used Google form, Wufoo form to try to securely capture the info
what I have: a google search form (displayed on all pages) a wordpress page
Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout
I have a form in google app engine where I want to upload an
I have made a simple web form in Google app engine where I have
I have created a simple web app/form using google app engine. the site is
I have a form that is capturing data sent from a google LocalSearch API.
I have google analytics on my site. One page has a button which when

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.