Select multiple data validation objects respectively

MeiR_ct

New Member
Joined
Feb 22, 2009
Messages
43
Hi all,
I have a VBA function that performs a search in another sheet, and returns bunch of found row numbers, in a collection.
Now, in my procedure, the code loops on the results and creates 3 comma separated lists, based on info from the rows.
Code:
    For i = 1 To FoundRows.Count
        rownum = CLng(FoundRows(i))
        With Sheets(SheetToSerach)
            resID = resID & ", " & .Cells(rownum, "A").Value
            resName = resName & ", " & .Cells(rownum, "E").Value
            resAddr = resAddr & ", " & .Cells(rownum, "F").Value
        End With
    Next i
    'Remove first comma+space
    resID = Mid(resID, 3)
    resName = Mid(resName, 3)
    resAddr = Mid(resAddr, 3)
Afterwards, these 3 lists are added to a 3 cells in the handled row, as validation data lists.
Code:
    With Cell(r, IDCol).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=resID
    End With
    With Cell(r, NameCol).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=resName
    End With
    With Cell(r, AddrCol).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=resAddr
    End With
Now, I want that when some object in one of these lists is selceted, the 2 other lists will change to same object number respectively.
Here is an example of 3 cells, which have lists that contain 4 lines each:

--- D5: ---------- D6: ------------ D7: ---------
558097913 ______ John _______ John's Address
234957124 ______ Bill _______ Bill's Address
305053132 ______ Peter _______ Peter's Address
280894561 ______ Adam _______ Adam's Address

The idea is when a user selects "Bill" in D6's list, then D5 and D7 cells will change to Bill's ID and address. Same if user selects some ID, or some address.


Some other question: What is a best way I can "tie" the 3 lists together respectively always, so there won't be mismatch between details?
Maybe to store them in other manner?
Having them as plain sheet data is not acceptable, since there are thousands of searches, which means thousands of result lists.


Thanks a lot in advance!
Meir.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Meir,

While it is possible (but not simple) to link the validation lists, have you considered using multi-column in-cell listboxes (ListBox controls) instead? You can approximate the functionality of cell validation lists by using a Worksheet_SelectionChange event to pop up the appropriate listbox by making it visible.

Damon
 
Upvote 0
To be honest, I have seen some posts that suggesting ListBox\ComboBox rather than data validation drop down list.

Can you please help me with an event code and storing loops that will suit my needs as I detailed above?

Thanks in advance, Meir :)
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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