Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to create a long validation list?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default How to create a long validation list?

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
wrote in message
oups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Validation and a Long List. An Easier Way? [email protected] Excel Discussion (Misc queries) 0 August 24th 07 04:40 PM
Search for a specific entry in a long data validation list Heinrich Excel Discussion (Misc queries) 1 May 4th 07 07:29 PM
Formula too Long for List Validation JB Excel Discussion (Misc queries) 3 April 6th 07 07:11 PM
How to Create a macro from drop down list (Validation List) in excel [email protected] Excel Programming 0 October 31st 06 12:42 PM
A better way to create this function. To long for Data Validation. Niklas[_5_] Excel Programming 9 February 19th 04 07:28 AM


All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"