+ Reply to Thread
Results 1 to 7 of 7

Application.AddCustomList, Method Error

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    Norwalk, CT
    MS-Off Ver
    Excel 2010
    Posts
    80

    Application.AddCustomList, Method Error

    Hi,

    Why am I getting an error message here?

    deleteme2.xlsx

    Sub macro1()
    
    Application.AddCustomList Sheets(1).Range("J1:J7")
    'Range("A1").CurrentRegion.Sort key1:=Range("A1"), OrderCustom:=Application.CustomListCount + 1
    'Application.DeleteCustomList Application.CustomListCount
    
    End Sub

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Application.AddCustomList, Method Error

    You can't delete the first four lists.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-18-2012
    Location
    Norwalk, CT
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Application.AddCustomList, Method Error

    Sorry, its not clear. Notice the ' before the last couple lines of code.

    When trying to just add J1:J7 as a custom list I get the error, "Method 'AddCustomList' of object '_Application' failed"

  4. #4
    Registered User
    Join Date
    05-18-2012
    Location
    Norwalk, CT
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Application.AddCustomList, Method Error

    No, I have numbers in those cells "J1:J7"

    How can I sort column A...for example...using "J1:J7" as a custom filter?
    Last edited by niko79542; 07-24-2012 at 04:37 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Application.AddCustomList, Method Error

    You have text in those cells? That's what custom lists are made of.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Application.AddCustomList, Method Error

    convert the numbers (eg prefix them with an apostrophe) to text then create the list
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Registered User
    Join Date
    05-18-2012
    Location
    Norwalk, CT
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Application.AddCustomList, Method Error

    Thx bro,

    I didn't think of that...I kept trying to add characters at the end of the number which wasn't quite working out..Anywayz heres the correct code.

    Niko


    Sub macro1()
    Dim i As Integer
    
    For i = 1 To 7
    
    Cells(i, 10) = "'" & Cells(i, 10)
    Next i
    
    Application.AddCustomList Sheets(1).Range("J1:J7")
    Range("A1").CurrentRegion.Sort key1:=Range("A1"), OrderCustom:=Application.CustomListCount + 1
    Application.DeleteCustomList Application.CustomListCount
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1