I cant seem to figure out how to put this script to skip column L. I tried many different varieties but all result in error. I hope somebody with more experience can shed light. I need I:K and M:O without L.
sheet1.getRange("I1:O"+sheet1.getLastRow()).getValues()
As a simpl modification, how about the following modification?
sheet1.getRange("I1:O"+sheet1.getLastRow()).getValues()
sheet1.getRange("I1:O"+sheet1.getLastRow()).getValues().map(([i,j,k,,m,n,o]) => [i,j,k,m,n,o]);
or
sheet1.getRange("I1:O"+sheet1.getLastRow()).getValues().map(([i,j,k,,...mno]) => [i,j,k,...mno]);
Another approach:
const array = sheet1.getRange('I1:O'+sheet1.getLastRow()).getValues();
array.forEach(a => a.splice(3, 1));
In more detail, 3 is chosen because, starting from 0, L is at the third position: I, J, K, L.
Code snippet:
function myFunction() {
const ss = SpreadsheetApp.getActive();
const sheet1 = ss.getSheetByName('Sheet1');
const array = sheet1.getRange('I1:O'+sheet1.getLastRow()).getValues();
array.forEach(a => a.splice(3, 1));
console.log(array);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With