Consulting

Results 1 to 2 of 2

Thread: Data validation.........vba array

  1. #1
    VBAX Regular
    Joined
    Apr 2010
    Posts
    32
    Location

    Data validation.........vba array

    Is it possible to use a vba array as a list in Data Validation?

    And then also do a vlookup on the array?

    Thanks!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by sconly
    Is it possible to use a vba array as a list in Data Validation?
    Not so far in my explorations..
    I suppose you could arrange for the vba to write the array to a sheet, to have a dynamic name refer to that range and use that name in the Data Validation source field. In fact, if the list remains the same size, you could put an array-entered formula there eg. {=myaray} which will update itself each time the Name is updated.
    ..but I feel someone will be cleverer than that.

    Quote Originally Posted by sconly
    And then also do a vlookup on the array?
    Yes, via a name, but the name has to be updated each time the array xxx changes:
    [vba]Dim xxx(4, 5)
    For i = 0 To UBound(xxx, 1)
    For j = 0 To UBound(xxx, 2)
    xxx(i, j) = i * j + i + j * 33 'this can be anything
    Next j
    Next i
    ThisWorkbook.Names.Add "myary", xxx[/vba]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •