How can I order values in a spreadsheet using macro?

I was trying to set a macro to automatically put a table rows in ascending order, but the SetSort() method doesn’t work properly. How can i do that?

Hello @JonatasLima2511

Can you share an example of content that are trying to sort with SetSort method? If possible please share a sample spreadsheet for test and sample of macro you are executing that returns improper result.

Sure! I created the same table in two different positions of the spreadsheet to demonstrate and two different codes, one for each table but just the table in range “A1:C5” was ordered. (result - image 1).


image 1

Code:

(function()
{
    var sheet = Api.GetSheet("Test");
    sheet.GetRange("A1:C5").SetSort("A1:A5", "xlAscending", "B1:B5", "xlDescending", "C1:C5", "xlAscending", "xlYes", "xlSortColumns");
    sheet.GetRange("J4:L8").SetSort("J4:J8", "xlAscending", "K4:K8", "xlDescending", "L4:L8", "xlAscending", "xlYes", "xlSortColumns");
})();

Thank you. We are checking this scenario out, I will let you know once we get any results.

We have found out that currently SetSort indeed is bugged, based on received results we registered a bug and started working on it. You will receive a notification when this problem is fixed.

Please accept apologies for inconvenience caused.

Ok, thank you @Constantine !