LstCustomSelection_Refresh

Read list of items from Settings sheet, then Sort, then save, before reading them back into listbox control
Example here will read list of items starting "CustomSelectionName" like "CustomSelectionName1", "CustomSelectionName4", "CustomSelectionName3", etc until setting is missing
Needs ...
SettingRead(), SettingSave(), ArrSort_2Arr(), CboSet4 as listbox

Very custom, I know, but I will need this saved here since I plan to use on other tools.

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub LstCustomSelection_Refresh()
    ' Read list of items from Settings sheet, then Sort, then save, before reading
    ' Example here will read list of items starting "CustomSelectionName" like "CustomSelectionName1", "CustomSelectionName4", "CustomSelectionName3", etc until setting is missing
    ' Needs ...
    '        SettingRead(), SettingSave(), ArrSort_2Arr(), CboSet4 as listbox
    '
    Dim Arr1(), Arr2()
    Application.Calculation = xlCalculationManual
    X1 = 1
    Do
        CustomName = SettingRead("CustomSelectionName" & X1)
        If CustomName = "N/A" Then
            Exit Do
        ElseIf CustomName > "" Then
            ReDim Preserve Arr1(X1 - 1)
            ReDim Preserve Arr2(X1 - 1)
            Arr1(X1 - 1) = CustomName 'SettingRead("CustomSelectionName" & X1)
            Arr2(X1 - 1) = SettingRead("CustomSelectionGroupCompanies" & X1)
           
            SettingSave "CustomSelectionName" & X1, ""
            SettingSave "CustomSelectionGroupCompanies" & X1, ""
        ElseIf CustomName = "" Then
        End If
        X1 = X1 + 1
    Loop
    ' Sort
    ArrSort_2Arr Arr1, Arr2, 1, 0 ' Actually sort them
   
    ' Read them again
    CboSet4.Clear
    X1 = 1
    For I = 1 To UBound(Arr1) + 1 ' Then save them back into settings
        If Arr1(I - 1) > "" Then
            SettingSave "CustomSelectionName" & X1, Arr1(I - 1)
            SettingSave "CustomSelectionGroupCompanies" & X1, Arr2(I - 1)
           
            CboSet4.AddItem Arr1(I - 1)
            CboSet4.List(CboSet4.ListCount - 1, 1) = X1
            X1 = X1 + 1
        End If
    Next
   
    Application.Calculation = xlCalculationAutomatic
End Sub

N/A

Views 89

Downloads 42

CodeID
DB ID