Data Vlaidation based on a formula

James8761

Board Regular
Joined
Apr 24, 2012
Messages
154
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I have created a simle Data Validation List, based on whether a city says London, New York or Venice.

I would like to create a formula that says if Cell C3 says New York, the Data Validation List in Cell C5 will only let you select an item from Cells D9:D11, If Cell C3 says London C5 will only let you select an item from Cells C9:C13, If Cell C3 says Venice C5 will only let you select an item from Cells E9:E11.

Is this possible at all please?
 

Attachments

  • City Route.PNG
    City Route.PNG
    11 KB · Views: 3
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try:
VBA Code:
Sub CreateDVlist()
    Application.ScreenUpdating = False
    Dim fnd As Range, arr As Variant
    Dim LastRow As Long
    Set fnd = Rows(8).Find(Range("C3").Value, LookIn:=xlValues, lookat:=xlWhole)
    If Not fnd Is Nothing Then
        LastRow = Columns(fnd.Column).Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        arr = Application.Transpose(Range(Cells(fnd.Row + 1, fnd.Column), Cells(LastRow, fnd.Column)))
        With Range("C5").Validation
            .Delete
            .Add Type:=xlValidateList, Formula1:=Join(arr, ",")
        End With
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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