Linked Data Validation Tables

MeaclH

Board Regular
Joined
Apr 2, 2014
Messages
63
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I am wondering if there is a way to have 2 seperate cells with data validation that are linked somehow, so that when a value is selected in the first table, the other table value reflects the value from the table in the adjacent column. I'd like this to be done from either column, so if a user knows the name of a location but not the 3 letter code they can select that, or vice versa, if a user knows the 3 letter code but not the name they can select that, and the 2 data validation cells will always be matched up.
I am guessing it may be some kind of IF/VLOOKUP combo but have no idea.
Any ideas, I'd love to hear them.

cheers,
Hayden

DAO Almanac.xlsx
ABCDEFGHIJKLMNOPQRST
1CODELOCATION NAMELINE(s)Terminating LocationStabling LocationMeal Break LocationDrivers Depot# of Stabling Roads
2Burnley SidingsBLSACFAircraftWerribeeNONO
3ALBAlbionSunburyNONO
4ALMAlameinAlameinYESNONO
5ALPAlphingtonHurstbridgeNONO
6Terminating LocationYESALTAltonaWerribeeNONO
7Stabling LocationYESARMArmadaleFrankstonNONO
8Meal Break LocationYESASHAshburtonAlameinYESNONO
9Drivers DepotNOASPAspendaleFrankstonNONO
10Stabling Roads5ASVAscot ValeCraigieburnNONO
11LinesAlamein, Lilydale, BelgraveASYAnsteyUpfieldNONO
12AUBAuburnAlamein, Lilydale, BelgraveNONO
13BATBatmanUpfieldYESNONO
14BAYBayswaterBelgraveYESYESNO5
15BBHBrighton BeachSandringhamYESYESNO2
16BBNBlackburnLilydale, BelgraveYESNONO
17BCVBalaclavaSandringhamNONO
18BEGBelgraveBelgraveYESYESNOYES3
19BELBellMerndaNONO
20BENBentleighFrankstonNONO
21BEWBerwickEast PakenhamYESNONO
22BFDBeaconsfieldEast PakenhamNONO
Sheet1
Cells with Data Validation
CellAllowCriteria
G2:H4List=$M$2:$M$22
B2:E4List=$N$2:$N$22
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This is likely going to require some VBA as formulas cannot affect other cells, and I don't believe Data Validation can do that either. You could use a LOOKUP to pull one piece of data based off the other, but not both at the same time unless you used more than the two cells.
 
Upvote 0
This is likely going to require some VBA as formulas cannot affect other cells, and I don't believe Data Validation can do that either. You could use a LOOKUP to pull one piece of data based off the other, but not both at the same time unless you used more than the two cells.
Thanks mate. I thought it may be pushing the boundaries.
What about an input box that lets you search by either location or 3 letter code and then presents the information from a LOOKUP?
 
Upvote 0
That is doable, but is also VBA. And would the information be displayed in a popup message box, or displayed on the sheet?
 
Upvote 0
Why not use a Combo-box? For example:

1726185184888.png


You can put the combobox in A1:E1 as shown. If you use the dropdown, it looks like this:

1726185268034.png


Meaning that the user can see code and location. Once the user selects a line, the code goes into the G2 cell, and the location name goes into B2 via a lookup, and the E6:E11 values are looked up the same way. Let me know if this will work for you, and I can give you some instructions. It's easy, it'll take less than 5 minutes.

Here's the xl2bb extract - I used screen prints before since it doesn't show the control.

Book1
ABCDEFGHMNOPQRST
1Select CodeCODELOCATION NAMELINE(s)Terminating LocationStabling LocationMeal Break LocationDrivers Depot# of Stabling Roads
2AuburnAUBACFAircraftWerribeeNONO
3ALBAlbionSunburyNONO
4ALMAlameinAlameinYESNONO
5ALPAlphingtonHurstbridgeNONO
6Terminating Location ALTAltonaWerribeeNONO
7Stabling LocationNOARMArmadaleFrankstonNONO
8Meal Break LocationNOASHAshburtonAlameinYESNONO
9Drivers Depot ASPAspendaleFrankstonNONO
10Stabling Roads ASVAscot ValeCraigieburnNONO
11LinesAlamein, Lilydale, BelgraveASYAnsteyUpfieldNONO
12AUBAuburnAlamein, Lilydale, BelgraveNONO
13BATBatmanUpfieldYESNONO
14BAYBayswaterBelgraveYESYESNO5
15BBHBrighton BeachSandringhamYESYESNO2
16BBNBlackburnLilydale, BelgraveYESNONO
17BCVBalaclavaSandringhamNONO
18BEGBelgraveBelgraveYESYESNOYES3
19BELBellMerndaNONO
20BENBentleighFrankstonNONO
21BEWBerwickEast PakenhamYESNONO
22BFDBeaconsfieldEast PakenhamNONO
Sheet1
Cell Formulas
RangeFormula
B2B2=VLOOKUP(G2,$M$2:$T$22,2,0)
E6E6=VLOOKUP($G$2,$M$2:$T$22,4,0)&""
E7E7=VLOOKUP($G$2,$M$2:$T$22,5,0)&""
E8E8=VLOOKUP($G$2,$M$2:$T$22,6,0)&""
E9E9=VLOOKUP($G$2,$M$2:$T$22,7,0)&""
E10E10=VLOOKUP($G$2,$M$2:$T$22,8,0)&""
E11E11=VLOOKUP($G$2,$M$2:$T$22,3,0)&""
 
Upvote 0
I reckon
Why not use a Combo-box? For example:

View attachment 116796

You can put the combobox in A1:E1 as shown. If you use the dropdown, it looks like this:

View attachment 116797

Meaning that the user can see code and location. Once the user selects a line, the code goes into the G2 cell, and the location name goes into B2 via a lookup, and the E6:E11 values are looked up the same way. Let me know if this will work for you, and I can give you some instructions. It's easy, it'll take less than 5 minutes.

Here's the xl2bb extract - I used screen prints before since it doesn't show the control.

Book1
ABCDEFGHMNOPQRST
1Select CodeCODELOCATION NAMELINE(s)Terminating LocationStabling LocationMeal Break LocationDrivers Depot# of Stabling Roads
2AuburnAUBACFAircraftWerribeeNONO
3ALBAlbionSunburyNONO
4ALMAlameinAlameinYESNONO
5ALPAlphingtonHurstbridgeNONO
6Terminating Location ALTAltonaWerribeeNONO
7Stabling LocationNOARMArmadaleFrankstonNONO
8Meal Break LocationNOASHAshburtonAlameinYESNONO
9Drivers Depot ASPAspendaleFrankstonNONO
10Stabling Roads ASVAscot ValeCraigieburnNONO
11LinesAlamein, Lilydale, BelgraveASYAnsteyUpfieldNONO
12AUBAuburnAlamein, Lilydale, BelgraveNONO
13BATBatmanUpfieldYESNONO
14BAYBayswaterBelgraveYESYESNO5
15BBHBrighton BeachSandringhamYESYESNO2
16BBNBlackburnLilydale, BelgraveYESNONO
17BCVBalaclavaSandringhamNONO
18BEGBelgraveBelgraveYESYESNOYES3
19BELBellMerndaNONO
20BENBentleighFrankstonNONO
21BEWBerwickEast PakenhamYESNONO
22BFDBeaconsfieldEast PakenhamNONO
Sheet1
Cell Formulas
RangeFormula
B2B2=VLOOKUP(G2,$M$2:$T$22,2,0)
E6E6=VLOOKUP($G$2,$M$2:$T$22,4,0)&""
E7E7=VLOOKUP($G$2,$M$2:$T$22,5,0)&""
E8E8=VLOOKUP($G$2,$M$2:$T$22,6,0)&""
E9E9=VLOOKUP($G$2,$M$2:$T$22,7,0)&""
E10E10=VLOOKUP($G$2,$M$2:$T$22,8,0)&""
E11E11=VLOOKUP($G$2,$M$2:$T$22,3,0)&""
Hi Eric, I think this would work really nicely. If you can give me some advice on how to get the combo box set up that would be wicked.
Thanks heaps,
Hayden
 
Upvote 0
That is doable, but is also VBA. And would the information be displayed in a popup message box, or displayed on the sheet?
Hi mate,
I also think this could be an interesting way of presenting the infomation. Would be cool to populate the message box with the data from the table when either location or 3 letter code is input.
Perhaps you could share a sample?

Cheers,
Hayden
 
Upvote 0
OK, start with a COPY of your worksheet as you have it in your first post. Then click on the Developer tab. The Developer tab is not visible by default. If you haven't used it yet, click on File > Options > Customize Ribbon > then in the right box, scroll down until you see Developer, then put a check next to it and click OK.

Once on the Developer tab, click on Insert, and under the Active-X controls, find the Combo box icon (1st row, 2nd column), click on it, then use the mouse to "paint" the control on your worksheet where you want it. Then you can use the handles on the corners to move or resize it later. Right click on it, and select Properties. You should see this:

1726190418084.png


Change the column count to 2, and put the LinkedCell, and ListFillRange as shown to match your sheet. I'd also recommend changing the ColumnHeads to True, and maybe try putting 40;80 in the ColumnWidths section. You can play with the rest if you want to customize the control some more, but that's all you really need. Then go back to the Ribbon and toggle off the Design Mode button. Then insert the VLOOKUP functions from my previous post, and you should be good to go.

Let us know how this worked for you.
 
Upvote 0
Hi mate,
I also think this could be an interesting way of presenting the infomation. Would be cool to populate the message box with the data from the table when either location or 3 letter code is input.
Perhaps you could share a sample?

Cheers,
Hayden
With your sample data provided, this works with values entered into cell A2, and looks up the values in col M or N depending on the length of the value entered. Could a location name be less than 4 characters in length?
This will show the results in a message box, and if an invalid entry is entered, another message box will show informing the user the value was not found.
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim lookupval As String
Dim result As Long
Application.EnableEvents = False
On Error GoTo ExitNow
If Not Intersect(Target, Range("A2")) Is Nothing Then
    If Len(Target) = 3 Then
        lookupval = Target
        result = Range("M2:M22").Find(lookupval).Row
        MsgBox Range("N" & result) & " " & Range("M" & result), Title:="Location Info"
    Else
        lookupval = Target
        result = Range("N2:N22").Find(lookupval).Row
        MsgBox Range("N" & result) & " " & Range("M" & result), Title:="Location Info"
    End If
End If
ExitNow:
MsgBox "Invalid entry. Try again.", vbCritical, Title:="Value Not Found"
Application.EnableEvents = True
End Sub

Right click the sheet tab and select View Code. Paste the above code in the module that opens.
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,341
Members
451,638
Latest member
MyFlower

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