Data validation list using a function

insomniac53

Board Regular
Joined
Sep 3, 2013
Messages
104
I am trying to create a dropdown validation list on a sheet cell (not a form) using a function rather than a constant. I am doing this because the validation will be repeated on the same sheet for various columns, so rather than create 20+ Names, I thought I might be able to write a function which returns a string, identical to a constant string. So, the constant Name for column I is 'ValidCategories' and refers to this range:
Code:
='Lists Sheet'!$I$2:INDEX('Lists Sheet'!$I:$I,MATCH(REPT("z",255),'Lists Sheet'!$I:$I))
The function (abridged) is:
Code:
Public Function Valid_Range(id As Integer) As String
    'id selects the appropriate column 
    Dim s as String
    's creates same string as above for the selected column
    Valid_Range = s
End Function
The string function works okay, but the validation needs a specified list or Name. Is there a way around this or do I need a different approach?
Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If you want the same DD across a bunch of cells, why not just create the 1st 1, and copy across?
 
Upvote 0
Thanks, but the dropdowns (DDs?) are all different. The parameter in the function determines the dropdown contents. But like I say, the validation source won't accept the function, just a defined Name or list.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top