Reputation: 51
Hope you guys help me below question :
2. I want to use google app script to pull out the unique values like : HTS, WDS, HH 3. So I write below codes :
Upvotes: 1
Views: 141
Reputation: 27350
You can use Set and Spread syntax (...) to get the unique values of an array:
const uniqueArray = [...new Set(data)];
Adjust 'Sheet1'
to the name of your sheet:
function myFunction() {
const ss = SpreadsheetApp.getActive();
const sheet = ss.getSheetByName('Sheet1'); // put the name of the sheet
const data = sheet.getRange("J2:O2").getValues().flat();
const uniqueArray = [...new Set(data)].filter(v=>v!='');
console.log(uniqueArray)
}
Upvotes: 1