Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
ExcelScript.SortOn enum
- Package:
- ExcelScript
Represents the part of the cell used as the sorting criteria.
Remarks
Used by
Examples
/**
* This script sorts a range based on the color of the cells.
* It brings all red cells to the top of the range.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the range (A1:D8) to sort from the current worksheet.
const worksheet = workbook.getActiveWorksheet();
const rangeToSort = worksheet.getRange("A1:D8");
// Create a SortField for color sorting.
// This sorts the rows based on the fill color of each row's cell in the first column.
let colorSort: ExcelScript.SortField = {
ascending: true,
color: "FF0000", /* red */
key: 0,
sortOn: ExcelScript.SortOn.cellColor
};
// Apply the SortField to the range.
rangeToSort.getSort().apply([colorSort]);
}
Fields
| cellColor |
| fontColor |
| icon |
| value |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Scripts
Feedback
Was this page helpful?
