This topic is not presented in any way on the forum ... Or am I mistaken?
Dynamic sorting by unsaved user criteria (sequence of values) entered directly on the sheet.
And the topic is very interesting, as it turned out ... I ask you to post your developments, if any, of course.
Excel Custom Lists: Demo Code (Application: .AddCustomList, .GetCustomListNum, .DeleteCustomList)
https://docs.microsoft.com/en-us/office ... customlist
Code: Select all
Sub SortRange()
Dim nIndex&
Application.AddCustomList ListArray:=Worksheets("1").[U4:U9]
nIndex = Application.GetCustomListNum(Worksheets("1").Range("U4:U9").Value)
Range("B5:K400").Sort Key1:=Range("B5"), Order1:=xlAscending _
, Key2:=Range("C5"), Order2:=xlAscending, Header:=xlNo _
, Orientation:=xlSortColumns, OrderCustom:=nIndex + 1 'custom list array is one based
Application.DeleteCustomList nIndex
End Sub
LibreOffice Demo Code: An example of adding a new user defined sort list.
Code: Select all
Dim aUserLists$(), ListArray, sList$, nEnd%
ListArray = Array("Item1", "Item2", "Item3")
sList = Join(ListArray, ",")
Dim aUserLists$()
oSettings = createUnoService("com.sun.star.sheet.GlobalSheetSettings")
aUserLists$ = oSettings.getPropertyValue("UserLists")
nEnd = UBound(aUserLists) + 1
ReDim Preserve aUserLists(nEnd)
aUserLists(nEnd) = sList
oSettings.setPropertyValue("UserLists", aUserLists)