google apps script - Copy Cell one sheet to another if not a duplicate based on criteria in multiple cells -
this follow-up previous post, not figure out how add prior post. here link prior post. copying data sheet1 sheet2 can sort & edit both sheets (google apps script?)
part ii daniel, have following on sheet1 (participant_registration) there button when pushed adds id both sheet1 , sheet2 (learning_sessions_attendance). used vlookup function transfer columns b-d sheet1 sheet2 wrote own script add instructions participants.
now here need now. small fix original script script, while fantastic, starts numbering id’s @ 2 instead of @ 1. there way fix this?
new script on sheet1 (participant_registration) if column l, m, or n have value = “group1” id (in column a) transferred sheet3 (consultation1_attendance). if l, m, or n have value = “group2” id in (column a) transferred sheet4 (consultation2_attendance).
here considerations new script, have made hard me write it. during course of training, people may change groups, means function needs onedit function , cannot transfer last row. needs transfer active row , transfer consultation attendance form if id not on form. tried query formula - not work cannot sort rows in consultation attendance sheet, , adding new data sheet.
note: play script have 10 possible consultation groups. i’m not sure if there way automate copying sheet consultation1_attendance number of groups , populating people assigned group.
here link sheet. https://docs.google.com/spreadsheets/d/1cvko2tpkezdlwhc2xvfli8lyvylxcas4vgsg-wb_llm/edit?usp=sharing
the code under code.gs runs. attempts @ code under consultgpassign.gs (they sad attempts). learning. have been trying kinds of things , use help.
i pasted 1 attempt not working here.
function onedit(event) { var ss = spreadsheetapp.getactivespreadsheet(); var s = event.source.getactivesheet(); var r = event.source.getactiverange(); if(s.getname() == "participant_registration" && ((r.getcolumn() == 12 && r.getvalue() == "group1") || (r.getcolumn() == 13 && r.getvalue() == "group1") || (r.getcolumn() == 14 && r.getvalue() == "group1"))) { var row = r.getrow(); //not sure if works //only want transfer id column not sure how var numcolumns = s.getlastcolumn(); var targetsheet = ss.getsheetbyname("consultation1_attendance"); var target = targetsheet.getrange(targetsheet.getlastrow() + 1, 1); s.getrange(row, 1, 1, numcolumns).moveto(target); //only want transfer information if it's not on sheet. not want delete } }
looking @ line:
s.getrange(row, 1, 1, numcolumns).moveto(target); //only want transfer information if it's not on sheet. not want delete
the moveto()
method cuts range. comment states don't want delete. cutting range delete it. have target range defined. use getvalues()
want copy:
var myvaluestocopy = s.getrange(row, 1, 1, numcolumns).getvalues(); target.setvalues(myvaluestocopy);
Comments
Post a Comment