Need help to create a dynamic data validation list box

dilfred

New Member
Joined
Jul 22, 2015
Messages
6
I have a column of unique part numbers created using this code and extracting it from "input" sheet.
This code is then copied down column B on a new sheet called "lists"
Code:
{=INDEX(INPUT!$A$6:$A$936, MATCH(0, COUNTIF($B$1:B1, INPUT!$A$6:$A$936), 0))}
I have made this list currently "much longer" than the number of unique items I have (and number of lines currently on "input" sheet, however anticipate that it could potentially be 200+ items by the end of the tolerance analysis.
This is then defined as a list
However once it gets to the bottom of the unique part numbers on the input sheet column B starts to report 0 then n/a n/a n/a etc.

input sheet is something like this
fred1
fred1
fred1
fred1
fred1
fred1
greg1
hedge1
hedge1
hedge1
hedge1
zedge1
zedge1
zedge1

lists sheet is something like this:

fred1
greg1
hedge1
zedge1
0
#N/A
#N/A
#N/A
#N/A
#N/A
#N/A
...
EG, these are the 4 unique item numbers in the list on "input" sheet

This is fine, however I am using the list for a data validation list and I don't want the data validation list to include the N/A's or the last 0, I only want the data validation list to give me the "real" part numbers, not the extra invalid ones at the bottom.

Is there any way to make the data validation list adaptive, so that it looks at this list and only selects part numbers?
The way I've previously made them "dynamic" is defining the data list as a table, that way whenever something is added at the bottom, the list updates automatically, however I cannot work out how to make the table expand automatically as another unique item is added on the "input" sheet.

I also tried something like this, but it's not quite there as again it includes the 0, n/a.... etc.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then ' selects and sorts column "B"
'  Columns(Target.Column).Sort _      ' this line and the next 3 sort the column alphabetically, but not necessary as input sheet already sorts them.
'    Key1:=Cells(2, Target.Column), Order1:=xlAscending, _
'    Header:=xlGuess, OrderCustom:=1, _
'    MatchCase:=False, Orientation:=xlTopToBottom
  Target.CurrentRegion.Name = "Lst_Part_Nos"
End If
End Sub

The list of part numbers on "index" sheet is being used in a dependant data validation list like this :- http://www.contextures.com/xlDataVal02.html, but that is not relevant to the question, just giving further context.

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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