Data Validation List with dynamic list depending on related cell content

mhoukes

New Member
Joined
Dec 28, 2018
Messages
3
Maybe a hard to explain title, an example:

A list of products, with a value per year:

A
B
C
1
Product
2018
2019
2
Apple
10
3
Pear
8
9
4
Melon
12
5
Orange
4
5
6
Lemon
2
7
Coconut
11
12

<tbody>
</tbody>


I'm searching for a solution to have a Data Validation List (Or filtered name range) of products with a non empty value in 2019 (so in the example: Pear Orange and Coconut) as selectable items in a data validation drop down list (in another cell).
List must be dynamic, when add a value under 2019 for Apple, Apple must be part of the list as well.

Seems not a difficult question but can't find any related question or example which i can use to compose my own formula or procedure.

Thanks for helping me out.

Marcel Houkes
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
A small add-on, I think the easiest thing to accomplish this is to create a dynamic conditional name range.
Name range of products where related 2019 cell <> "". When done so, then I reach the same goal, how....
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a value in a blank cell in column C and exit the cell. The drop down list will be created in cell D1.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("C:C")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim LastRow As Long, rng As Range, join As String
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rngArray As Variant
    For Each rng In Range("C2:C" & LastRow)
        If rng <> "" Then
            join = join & rng.Text & ", "
        End If
    Next
    With Range("D1").Validation
        .Delete
        .Add Type:=xlValidateList, Formula1:=Left(join, Len(join) - 2)
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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