Automatically copy data from sheet to sheet

760 views
Skip to first unread message

Pablo Wolf

unread,
Mar 27, 2023, 1:13:53 PM3/27/23
to Google Apps Script Community
Hey everyone! I need some help with my apps script code to get it to automatically copy data from one sheet to another.
So the sheet in question is linked to a Google Form, and whenever the google form is filled out the data gets transferred into a sheet named "Form Respones" (9 named columns). Now, I would like my spreadsheet to automatically copy columns 3 to 9 from any row from any row that appears on "Form Responses" to a sheet called "Assessment".

This is the code I made but does not work:

function copyData(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var origin_sheet = ss.getSheetByName("Form Responses 3");
  var origin_range = origin_sheet.getRange(2,3,1000,9)
  var dest_sheet = ss.getSheetByName("Assessment");
  origin_range.moveTo(dest_sheet.getRange(dest_sheet.getLastRow()+1,1,1,7))
}


Any sort of help would be appreciated. Thanks.

Ian Crew

unread,
Mar 27, 2023, 1:35:12 PM3/27/23
to google-apps-sc...@googlegroups.com
I’m probably missing something here, but is there a reason you’re not just using the Sheets “IMPORTRANGE” function to get columns 3 and 9 over into the Assessment sheet, no scripting necessary?

Cheers,

Ian

The contents of this message and any attachment(s) are confidential, proprietary to the City of Edmonton, and are intended only for the addressed recipient. If you have received this in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination, or distribution of this message, if misdirected, is strictly prohibited.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/02211aad-c66b-4e96-8e01-7e8554b7dd5fn%40googlegroups.com.
--
Ian Crew

Solutions Architect
Productivity & Collaboration Services
Information Services and Technology

Pablo Wolf

unread,
Mar 27, 2023, 1:43:30 PM3/27/23
to google-apps-sc...@googlegroups.com
Hey Ian, I have looked into using the IMPORTRANGE function, but the reason I want to use apps script is because my boss challenged me to strictly use coding so that I can learn it faster.

Regards,

Pablo

You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/gWoljOYrJpE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAD2sLFuLQGXr3A1cTZ_jzfru7oLT-7JhOfzbZghKVXPwnV8v%2BQ%40mail.gmail.com.


--

Edmonton_sig_RGB_S.jpg

Pablo Barba Wolf

Co-op Student

LRT Operations & Maintenance

City Operations  | Edmonton Transit Services


780-292-2446 MOBILE


City of Edmonton

D.L. MacDonald Transit Yard

ROW Building

13304-50A Street

Edmonton AB T5A 4P6


All information contained in this email post is proprietary to the City of Edmonton, confidential, and intended only for the addressed recipient. If you have received this post in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination, or distribution of this email, if misdirected, is strictly prohibited.


Reply all
Reply to author
Forward
0 new messages