Mar 23 2022 09:08 AM
I am trying to sort in descending order the cells with a 'rose' background, as you can do in the 'filter' or 'custom sort' but with ExcelScript for web:
range.getSort().apply([ {
ascending: false,
key: 5,
sortOn: ExcelScript.SortOn.cellColor,
subField: "rose"
}]);
But it does not sort. I am pretty sure I am misusing the subField field, but the microsoft docs are not very helpful. If I just sort in ascending or descending order, it works:
range.getSort().apply([ {
ascending: true,
key: 5
}]);
How can I use properly the sortOn feature to sort by cellColor, or other property?
I have tried to record a macro but it does not have the sortOn or subField fields:
selectedSheet.getRange("A8:K50").getSort().apply([{key: 0, ascending: true}], false, true);