+ Reply to Thread
Results 1 to 3 of 3

VBA to remove blanks from Drop Down List going above 255 characters HELP

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    2

    VBA to remove blanks from Drop Down List going above 255 characters HELP

    Hi

    I have some code that loops through a named range called People_Names to create a string called mylist that can be used in a drop down box.

    It works great except for when the string called mylist goes beyond 255 characters.

    This is my vba code.

    ' find all non empty people names
    myList = ""
    For Each name In People_Names
    If name = "" Then
    'do nothing
    Else
    myList = myList & name & ","
    End If
    Next name
    ' add the new list to the cells on allocations for people
    If myList = "" Then
    'do nothing
    Else ' update the list
    For n = 5 To 30
    With Allocation.Cells(n, 4).Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=myList
    End With
    Next n
    End If

    Is there an alternative method to get around this. I've tried creating a variable array and using that for the drop down but that didn't work either.,

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA to remove blanks from Drop Down List going above 255 characters HELP

    Hi,

    You need to use a range. No other method will work, unless you want to use code to remove the validation whenever the workbook is closed and reset it on opening again.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to remove blanks from Drop Down List going above 255 characters HELP

    An alternative could be to use ActiveX comboboxes instead of data validation.

    This will add comboboxes to cells D5:D50. You only have to run this one time to setup the comboboxes.
    Please Login or Register  to view this content.

    This will populate the comboboxes with the names
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. Remove blanks from list and sort
    By SubwAy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-24-2016, 10:23 PM
  2. [SOLVED] Remove Blanks From List
    By mafmouf in forum Excel General
    Replies: 7
    Last Post: 03-08-2013, 10:30 AM
  3. Excel remove blanks from list
    By evs1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2012, 12:33 PM
  4. How to remove blanks in the drop down list?
    By password636 in forum Excel General
    Replies: 10
    Last Post: 10-14-2010, 03:18 PM
  5. Remove blanks from a list
    By matrex in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-22-2009, 11:13 AM
  6. Remove blanks from list via VBA
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2005, 02:10 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