+ Reply to Thread
Results 1 to 5 of 5

Data Validation List Function

Hybrid View

  1. #1
    Registered User
    Join Date
    05-21-2010
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    7

    Data Validation List Function

    Hi!

    I'm trying to make a function that will output the name of the list a certain data validation cell is outputting it's information from. I want to do this so that I can use it for logic tests in if() functions.

    So simply put : CellDataListName("Cell name") -> "originating data list"

    I tried looking all over for that. I can't figure it out. Granted... I've never programmed before.

    Thanx a lot!!!
    Last edited by jrodri14; 05-22-2010 at 05:47 PM. Reason: Problem solved

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Data Validation List Function

    This UDF should do what you want.
    Function ValidationListSource(validatedCell As Range) As Variant
        Set validatedCell = validatedCell.Cells(1, 1)
        On Error GoTo NAError
        With validatedCell.Validation
            If .Type = 3 Then
                ValidationListSource = Mid(.Formula1, 2)
            Else
    NAError:
                ValidationListSource = CVErr(xlErrNA)
            End If
        End With
        On Error GoTo 0
    End Function
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    05-21-2010
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data Validation List Function

    Thanx a lot! I'll try it again tomorrow. BTW, is there any good site out there where I can learn some basics about the VB syntax?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Data Validation List Function

    I prefer to learn from books. I like Walkenbach's.

    Googling Excel VBA Tutorials gets a lot of hits.

    And, of course, there is this friendly help forum if you need help.

  5. #5
    Registered User
    Join Date
    05-21-2010
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Data Validation List Function

    Thank you! That worked incredibly well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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