Copying Row to another Google Sheet based on a Value

Devge

New Member
Joined
May 2, 2016
Messages
22
hey guys I am moving a row of data to another sheet based on column M being "completed" however, this is via google sheets and we use the comment section found in column H, but this is not copying over. Is there a solution that preserves the comment box in google sheets? I am using the following Script. Any help would be graciously accepted.

function copyrange() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Derek'); //source sheet
var testrange = sheet.getRange('M:M'); //range to check
var testvalue = (testrange.getValues());
var csh = ss.getSheetByName('Jons'); //destination sheet
var data = [];
var j =[];

//Condition check in H:H; If true copy the same row to data array
for (i=0; i<testvalue.length;i++) {
if ( testvalue == 'Credentials') {
data.push.apply(data,sheet.getRange(i+1,1,1,25).getValues());
//Copy matched ROW numbers to j
j.push(i);
}
}
//Copy data array to destination sheet

csh.getRange(csh.getLastRow()+1,1,data.length,data[0].length).setValues(data);

//Delete matched rows in the source sheet
for (i=0;i<j.length;i++){
var k = j+1;
sheet.deleteRow(k);

//Alter j to account for deleted rows
if (!(i == j.length-1)) {
j[i+1] = j[i+1]-i-1;
}
}
}
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top