PC Review


Reply
Thread Tools Rate Thread

How to create a long validation list?

 
 
haimcn@gmail.com
Guest
Posts: n/a
 
      23rd Nov 2006
Hi

I'm trying to create validation for a cell with a long list of names.
I started it with a naive attitude of:

mylist = ""
For I = 1 To 300
person = next person
If person should be added Then
mylist = mylist & IIf(mylist = "", "", ",") & person
End If
Next
With Target.Validation
.Delete
.Add xlValidateList, xlValidAlertStop, xlBetween, mylist, ""
...
End With

The problem with this issue is that the name list exceed 255 characters
so it is being cut.

I wanted to try to use it as an array or to define it as name but I
failed to define it correctly (I added my not working code at the end,
this is one solution I tried but maybe there is simpler)

I must do it pragmatically since I have several different conditions to
decide what value will be in the list and it changes for every cell.

Can any one supply me with the direction on how to do it?

Thanks
Haim

This code didn't work (the name creation is wrong, I don't know how to
do it):

Dim mylist As Variant
mylist = Array()

For I = 1 To 300
person = next person
If person should be added Then
mylist = Array(mylist, person)
End If
Next

Application.ThisWorkbook.Names.Add name:="workers", RefersTo:=mylist

With Target.Validation
.Delete
.Add xlValidateList, xlValidAlertStop, xlBetween, _
Formula1:="=workers"
...
End With

 
Reply With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      24th Nov 2006
I'm not sure I understand what you want to do. If you want to setup a Data
Validation/List in some cell and you want to create the list by VBA, simply
code your macro to place the names, one at a time, in some column somewhere
in your file, and name the list "mylist" when all the names have been
placed. Then setup the Data Validation. HTH Otto
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I'm trying to create validation for a cell with a long list of names.
> I started it with a naive attitude of:
>
> mylist = ""
> For I = 1 To 300
> person = next person
> If person should be added Then
> mylist = mylist & IIf(mylist = "", "", ",") & person
> End If
> Next
> With Target.Validation
> .Delete
> .Add xlValidateList, xlValidAlertStop, xlBetween, mylist, ""
> ...
> End With
>
> The problem with this issue is that the name list exceed 255 characters
> so it is being cut.
>
> I wanted to try to use it as an array or to define it as name but I
> failed to define it correctly (I added my not working code at the end,
> this is one solution I tried but maybe there is simpler)
>
> I must do it pragmatically since I have several different conditions to
> decide what value will be in the list and it changes for every cell.
>
> Can any one supply me with the direction on how to do it?
>
> Thanks
> Haim
>
> This code didn't work (the name creation is wrong, I don't know how to
> do it):
>
> Dim mylist As Variant
> mylist = Array()
>
> For I = 1 To 300
> person = next person
> If person should be added Then
> mylist = Array(mylist, person)
> End If
> Next
>
> Application.ThisWorkbook.Names.Add name:="workers", RefersTo:=mylist
>
> With Target.Validation
> .Delete
> .Add xlValidateList, xlValidAlertStop, xlBetween, _
> Formula1:="=workers"
> ...
> End With
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Validation and a Long List. An Easier Way? mark.wolven@gmail.com Microsoft Excel Misc 0 24th Aug 2007 04:40 PM
Search for a specific entry in a long data validation list =?Utf-8?B?SGVpbnJpY2g=?= Microsoft Excel Misc 1 4th May 2007 07:29 PM
Formula too Long for List Validation =?Utf-8?B?SkI=?= Microsoft Excel Misc 3 6th Apr 2007 07:11 PM
A better way to create this function. To long for Data Validation. =?Utf-8?B?TmlrbGFz?= Microsoft Excel Worksheet Functions 10 19th Feb 2004 07:28 AM
A better way to create this function. To long for Data Validation. =?Utf-8?B?TmlrbGFz?= Microsoft Excel Programming 9 19th Feb 2004 07:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:27 AM.