Office Script to apply "Sort number and numbers stored as text separately"

duger99

New Member
Joined
Nov 13, 2015
Messages
5
Hi friends - I have a situation where a sort field has been converted to text and is a mix of numbers and text. The values include numbers like "001", "002", etc. and values like "0.1, 066". When sorting this column in excel, it brings up a Sort Warning dialogue box and gives the option to "Sort numbers and numbers stored as text separately".

Screenshot 2023-09-27 193644.png


I would like to do this via an office script; however, I have been unsuccessful in finding a method to do so. Does it exist?

Here is the code I am using, which is part of a broader script:

JavaScript:
// Sort the range range A22:BW226 on selectedSheet
  portfolio_reporting.getRange("A22:BW226").getSort().apply([{ key: 1, ascending: true}], false, true, ExcelScript.SortOrientation.rows);

Thank you for your assistance!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
@ExcelToDAX - That options ends of sorting it where the numeric values (001, 002) are above "0.1, 066". The option "Sort numbers and numbers stored as text separately" puts the "0.1, 066" above "001".
 
Upvote 0
That is what you were asking for, to have an Office Scripts code that sorts the numbers and numbers stored as text separately. What are you trying to accomplish? What should the final output look like?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top