Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 494

have a code for copying rows from a sheet to another in google sheet but it do all of the rows not working for selected or filtered

$
0
0

i have a code for copying rows from a sheet (Parks) to another (Report) in google sheet. It works fine but the problem is, i have 335 rows in sheet 'Parks' and i don't want all of these rows in my Sheet 'Report'. i wanna apply filter on sheet 'Parks' so it might remain like 14 rows in sheet 'Parks'. i want the code to copy just these 14 rows not all of them (not all the 335 of them) but now the code is copying all of them.Anyone can help to modify the code?here is the code:

function copyDataFromParksToReport() {  var ss = SpreadsheetApp.getActiveSpreadsheet();  var parksSheet = ss.getSheetByName('Parks');  var reportSheet = ss.getSheetByName('Report');  reportSheet.getRange('A2:M').clearContent();  var parksData = parksSheet.getRange('A4:Q').getValues();  var reportData = [];  parksData.forEach(function(row) {    var newRow = [];    newRow[0] = row[16]; // Column Q -> Column A    newRow[1] = row[0]; // Column A -> Column B    newRow[2] = row[4]; // Column E -> Column C    newRow[3] = row[3]; // Column D -> Column D    newRow[4] = row[1]; // Column B -> Column E    newRow[5] = row[5]; // Column F -> Column F    newRow[6] = row[8]; // Column I -> Column G    newRow[8] = row[10]; // Column K -> Column I    newRow[10] = row[9]; // Column J -> Column K    newRow[12] = row[12]; // Column M -> Column M    // Get File ID from Google Drive links    if (row[6].includes("drive.google.com")) {      newRow[7] = row[6].split("/")[5]; // Column G -> Column H    } else {      newRow[7] = '';    }    if (row[11].includes("drive.google.com")) {      newRow[11] = row[11].split("/")[5]; // Column L -> Column L    } else {      newRow[11] = '';    }    reportData.push(newRow);  });  reportSheet.getRange(2, 1, reportData.length, reportData[0].length).setValues(reportData);}

i have tried getfilter class but didn't work.


Viewing all articles
Browse latest Browse all 494

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>