google apps script - Copy row values to a new sheet if it exist in another sheet -
I am new to Google Script and I have a script that is meant to be created. I have found this, where it should be removed in the row in any other sheet in the row. Now, my position is different here in my Google Spreadsheet, I have 3 sheets, the unique value that will be compared to the first two sheets, the first column is the "id number".
Looking at the values, It is equivalent that if ID ID is present in sheet 1 and 2, then it should be copied to sheet 3. I tried to modify the script, but I can not work: Thanks Any help / advice is highly appreciated. 784 | John Steip | IT department is present in the first 2 sheets, so the entire line should be copied to Sheet 3.
function copyRowtoSheet3 () {var s 1 = SpreadsheetApp.openById ( "1RlQTLZyPLasoJGplKemKg9qgcLcvCZZ_tPn6lWXEePw "). GetSheetByName ('sheet1'); Var s2 = SpreadsheetApp.openById ( "1RlQTLZyPLasoJGplKemKg9qgcLcvCZZ_tPn6lWXEePw") getSheetByName ( 'Sheet2'). VAR S3 = SpreadsheetApp.openById ( "1RlQTLZyPLasoJGplKemKg9qgcLcvCZZ_tPn6lWXEePw") getSheetByName ( 'sheets 3'). Var Value 1 = s1.getDataRange () GetValues (); Var Value 2 = s2.getDataRange () GetValues (); Var ResultsAll = []; (Var = n values1) {var for true = true (value 2 in var p) {if values1 [n] [0] == values2 [p] [0] and value1 [n] [1 ] = = Value 2 [p] [1]) {keep = false; break ; }} If (keep) {resultArray.push (value 1 [n])}; } S1.clear () s1.getRange (1,1, results too long, the result is [0]. Length) .SetVilz (Result Alternate); }
Not sure your situation work ... both sheets equal than the example outlined by Easy, just keep that data where parity == is correct. Try
Such (change IDs in):
function copyRowtoSheet3 () {var s 1 = SpreadsheetApp.openById ( "1x8buwr ______ w7MeqZAiJJIX0yC-oITBAtykBAM" ) GetSheetByName ('sheet1'). Var s2 = SpreadsheetApp.openById ( "1x8buwr ______ w7MeqZAiJJIX0yC-oITBAtykBAM") getSheetByName ( 'Sheet2'). VAR S3 = SpreadsheetApp.openById ( "1x8buwr ______ w7MeqZAiJJIX0yC-oITBAtykBAM") getSheetByName ( 'sheets 3'). Var Value 1 = s1.getDataRange () GetValues (); Var Value 2 = s2.getDataRange () GetValues (); Var ResultsAll = []; (Var n = 0; n & lt; values1.length; n ++) for {var keep = false; (Var p = 0; p & lt; values2.length; p ++) {logger.log (value 1 [n] [0] + '=?' + 2 values [p] [0]); If (value 1 [n] [0] == value 2 [P] [0] and amp; value 1 [n] [1] == value 2 [P] [1]) {Prinamarere present (value 1 [N ]); Logger.log ('true'); the break; Remove // if the value is not unique and you want to keep all the events ...}}} s3.getRange (+ 1,1, Prinamarere. Cross, Prinamarere [0]. Length) Ksetvolugh (Prinamarere); }
Comments
Post a Comment