Forum Discussion
TaurusGear13
Mar 13, 2025Copper Contributor
Office Scripts Custom Sort Failing During Automation
I am attempting to use office scripts within a OneDrive Excel document within Microsoft Teams to run a custom sort. Using the "Record Action" feature, I simply attempted to sort the range H3:J28 via ...
- Mar 13, 2025
Please try
function main(workbook: ExcelScript.Workbook) { const sheet = workbook.getActiveWorksheet() const range = sheet.getRange("H3:J28") const rangeSort: ExcelScript.SortField = { ascending: true, key: 0, sortOn: ExcelScript.SortOn.value } range.getSort().apply( [rangeSort], false, // case insensitive false, // no headers ExcelScript.SortOrientation.rows ) }
lli99
Mar 26, 2025Copper Contributor
Hello, I have a similar issue but with two custom sort levle, but keep getting errors please help:
}// Custom sort on range range A2:AV610 on selectedSheet
selectedSheet.getRange("A2:AV610").getSort().apply([{ key: 5, ascending: true }, { key: 0, ascending: true }], false, true, ExcelScript.SortOrientation.columns);