PDA

View Full Version : Solved: CustomList Index



kunguito
06-27-2008, 07:08 AM
I create via code a CustomList. Alternatively in Excel, Tools/options->Custom List
Dim ex As Excel.Application
Dim List() As String
List=Array("...","...","...")
ex.AddCustomList List

I use it as an OrderCustom parameter to sort a Range as follows:

Index.CustomList=ex.CustomListCount + 1

Rg.Sort key1:=ws.Columns("C"), Order1:=xlAscending, OrderCustom:=IndexCustomList, MatchCase:=False, Orientation:=xlTopToBottom

And then I delete the Custom List.

Now the tricky part: If the CustomList already exists how could I know its index (IndexCustomList)?

Thanks!

Bob Phillips
06-27-2008, 07:32 AM
Dim ListIndex As Long

ListIndex = Application.GetCustomListNum(Array("...", "...", "..."))
If ListIndex > 0 Then

MsgBox "List already exists, item #" & ListIndex
End If

kunguito
06-27-2008, 07:38 AM
Thanks XLD!