Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom list

Status
Not open for further replies.

drrocket5292

Technical User
Sep 6, 2005
73
US
how do you define a custom list in VBA and then call it? heres my code but it doesnt seem to work. Right now I have that list as my custom list #13 but its not like that on other peoples computers and I want to have a universal custom list. is this possible? thanks for the help.

Application.AddCustomList Array ("40", "36", "41", "48", "38", "54", "35", "3", "42", "2")

Range("A2:R" & n).Select
Range("R" & n).Activate
Selection.Sort Key1:=Range("R2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=13, MatchCase:=False, Orientation:=xlTopToBottom
 
I think the problem is the assumption that your CustomList will be #13 on every machine. Use this to discover what CustomList it is on the target machine.
Code:
[b]lngCustomListNumber = Application.GetCustomListNum(Array ("40", "36", "41", "48", "38", "54", "35", "3", "42", "2"))[/b]
Range("A2:R" & n).Select
    Range("R" & n).Activate
    Selection.Sort Key1:=Range("R2"), Order1:=xlAscending, Key2:=Range("C2") _
        , Order2:=xlAscending, Header:=xlGuess, _
        OrderCustom:=[b]lngCustomListNumber[/b], MatchCase:=False, Orientation:=xlTopToBottom
Hope this helps,
CMP

Instant programmer, just add coffee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top