+ Reply to Thread
Results 1 to 5 of 5

Issue with List Array

Hybrid View

  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Issue with List Array

    Hi Guys,

    can someone please tell me why there is an error in the following code, line in bold?

    Dim MyArray As Variant
    For Each x In ThisWorkbook.Sheets(1).Range("N2:N663")
    MyArray = MyArray + x + Chr(44)
    Next

    With ThisWorkbook.Sheets(1).Range("N1").Validation
    .Delete
    .Add Type:=xlValidateList, Operator:=xlBetween, Formula1:=Join(MyArray, ",")
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
    End With

    thanks
    V

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Issue with List Array

    Try this:-
    Sub MG24Mar35
    Dim MyArray As Variant
    
    MyArray = ThisWorkbook.Sheets("Sheet1").Range("N2:N663").value
    
    With ThisWorkbook.Sheets("sheet1").Range("N1").Validation
    .Delete
    .Add Type:=xlValidateList, Operator:=xlBetween, Formula1:=Join(Application.Transpose(MyArray), ",")
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
    End With
    End Sub
    Regards Mick

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Issue with List Array

    Also remember that limit for validation list text formula is 255 characters.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Issue with List Array

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Never use Merged Cells in Excel

  5. #5
    Registered User
    Join Date
    02-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Issue with List Array

    thanks Mick & Izandol...I was not aware of the character limit.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 12-23-2013, 08:43 AM
  2. [SOLVED] Array Unique list Issue
    By Enigmatise_1981 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-18-2013, 05:13 AM
  3. VBA Macros Array List Issue
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-15-2013, 01:48 PM
  4. search for a part of string within an array of strings from another array list
    By jdonohue in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2011, 01:32 PM
  5. Replies: 0
    Last Post: 07-27-2005, 11:05 AM

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