Why this command doesn't work on Excel Scripts (TypeScript)?

Fedix 0 Reputation points
2024-03-29T17:09:55.01+00:00

Hello all,

I would like to know why this command doesn't work at all.

I've tried every platform (Online and Offline Software) and this command doesn't work either, also if I'm trying to record this, Excel shows up with an error: "Unable to record this action".

This is the standard script that comes from Excel when I'm trying to share this action:

 let selectedSheet = workbook.getActiveWorksheet();

    // Sort the range range G4:L4 on selectedSheet

    selectedSheet.getRange("G4:L4").getSort().apply([{ key: 0, ascending: false }], false, true, ExcelScript.SortOrientation.rows);

It seems the SortOrientation by Row doesn't ever be applied.

In addition, I tried to ask this question in the Microsoft community but I was redirected here.

Also, I tried the two workaround suggested:

You may try changing the range being sorted to a larger range, such as "G4:L10", to see if the issue persists. Additionally, you can try using the SortFields object to specify the sort order instead of passing an array of objects to the apply method.

Unfortunately, still doesn't work.

Office
Office
A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.
1,638 questions
Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,892 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,908 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.