Using VBA to control Custom Lists - Excel Off The Grid

PHOTO EMBED

Sat Sep 07 2024 03:54:33 GMT+0000 (Coordinated Universal Time)

Saved by @acassell

'Find the listNum of a Custom List based on all items
Dim listNumFound As Integer
listNumFound = Application.GetCustomListNum(Array("Element1", "Element2", "Element3"))


'Find a Custom List which contains a specific element 
Dim i As Integer
Dim arrayItem As Variant
Dim customListContents() As Variant
Dim listNumFound As Integer

For i = 1 To Application.CustomListCount

    'Set the CustomList array to a variable
    customListContents = Application.GetCustomListContents(i)

    'Loop through each element in the CustomList
    For Each arrayItem In customListContents

        'Test if the element has a specific value
        If arrayItem = "Element1" Then listNumFound=i

    Next arrayItem

Next i
content_copyCOPY

https://exceloffthegrid.com/vba-for-customlists-autofill-lists/