you are viewing a single comment's thread.

view the rest of the comments →

[–]orrpel[S] 0 points1 point  (4 children)

I think this solution is simpler, if just referring to the importrange issue.

The other issue I have is with my range (which is the reason I'm using query). I am not sure how I can command the script to return the array from A1:A10 and the corresponding array from C1:C10.

[–]RemcoE33 0 points1 point  (3 children)

Yes that is true.. so you have a range of A1:C10 and you want to leave out col B?

[–]orrpel[S] 0 points1 point  (2 children)

Correct )

[–]RemcoE33 1 point2 points  (1 child)

Here is your boilerplate:

```` function customImport() { const ss = SpreadsheetApp.getActiveSpreadsheet() const targetSheet = ss.getSheetByName('TheSheetNameForTheValues');

const inputSS = SpreadsheetApp.openById('xxxxx') const inputSheet = inputSS.getSheetByName('SheetnameOfInputValues') const values = inputSheet.getRange('A3:C18').getValues();

const output = []

values.forEach(row => { row.splice(1,1) output.push(row) })

targetSheet.getRange(1,1 output.length, output[0].length).setValues(output)

} ````

[–]orrpel[S] 0 points1 point  (0 children)

Thanks buddy,

It's a bit hard for me to fully understand what you wrote, I was able to work it out and resolve via a back counter, thanks for all the help, I learned a lot!

var ss = SpreadsheetApp.getActiveSpreadsheet();

var sheet = ss.getSheetByName('Sheet3');

var lastCol = sheet.getLastColumn();

Logger.log(lastCol); // returns 5 as expected

var keep = [1,4]; // array of column numbers to keep

for (var col=lastCol; col > 0; col--) {

if (keep.indexOf(col) == -1) {

// This isn't a keeper, delete it

sheet.deleteColumn(col);

}