Data Validation List without duplicates

dsubash

New Member
Joined
Nov 22, 2024
Messages
32
Office Version
  1. 2019
  2. Prefer Not To Say
Platform
  1. Windows
Dear experts,

I have a database in Sheet 1, which contains the following fields
Col. A - List of Branches (Contains Duplicate Entries)
Col. B - List of Products (Contains Duplicate Entries) - certain products are unique to only certain branches while few products are available in all branches.
Col. C - Col. M - other details.

This sheet contains more than 10000 records containing the transactions for a particular month.

I need to prepare a report in Sheet 2 with the Branch and Product as criterias.
In Cell. A2, I have created a dropdown list for branches (after removing duplicates) and used Name Manager to create a Data Validation List.
I need the following in Cell B2 (Sheet 2)
a. A dropdown list of products from Col. B of Sheet 1
b. I need only the products list available against the branch selected in Cell A1 and should not display the products that are not available in the specific branch.
c. Duplicate product names to be removed and only unique names to be available in the dropdown list.
d. Option for autofill product names when one or more characters are typed.
e. Dropdown list should not contain blank entries
f. If possible Product names to be alphabetically displayed.

I tried to use Vlookup and for listing products against each branch in different columns, tried removing duplicates from this list in another column and using name manager for each branch. But since my list of branches and Products are more (20 + branches and 500 + products), I found it difficult to create multiple columns for vlookup and removing duplicates. Also had the problem of blanks in the drop down.

Is there any other options (VBA Code) to get what i want. I am using Office 2019 Professional and hence cannot use formulas avaialble in later versions (Sort / Unique, etc).

I tried viewing many threads in the forum, but was unable to find what i want. Threads available were mostly for higher versions of excel.

Thanks and regards
Subash D
 

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.
Is there any other options (VBA Code) to get what i want. I am using Office 2019 Professional and hence cannot use formulas avaialble in later versions (Sort / Unique, etc).
1. To arrange a set of dependent data validation, you can try this method:
3 level dependent data validation, with a macro to create a helper table.
Note: to make things easier, you can add a command button on the sheet to run the macro to refresh/recreate the table.
2. To get autocomplete data validation via a dynamic combobox, try this add-in:
Search deList
 
Upvote 0
Pl post sample data, preferably in XL2BB format.
Dear Murthy,

Please find below the sample file in XL2BB format

Sheet 1 (Database)
Sample Data - 25-12-2024.xlsm
ABCDEFG
1BranchProductTypeUOMDateInv. No.Price
2Sydney0.1ml 96 well PCR PlateGlasswareNos01/12/202455970
3Ireland0.2ml 96 well PCR Plate-25'sGlasswareBox02/12/202456013
4Japan0.2ml PCR 8 StripGlasswareBox02/12/202456014
5Tokyo8 Strip CapsGlasswarePkt02/12/202456018
6DelhiAcid Fast Stain KitChemicalBox02/12/202456020
7OhioAutobio-Cuvette 1000'sReagentNos02/12/202456021
8New JerseyAVE-Buffer 40mlReagentBox02/12/202456022
9BangkokAVE-Cleanser I-500mlReagentBox02/12/202456023
10BangaloreAVE-Cleanser II-40mlReagentBox02/12/202456024
11New JerseyBarium Chloride 10% 500mlReagentBox02/12/202456026
12BangkokBenzidine Powder-25gmReagentNos02/12/202456027
13BangaloreBiomedical Waste Cover Blue-MediumReagentNos02/12/202456029
14TokyoBiomedical Waste Cover Green-SmallReagentNos02/12/202456036
15DelhiBiomedical Waste Cover Red-MediumReagentNos02/12/202456037
16OhioBiomedical Waste Cover Yellow-MediumReagentNos02/12/202456039
17New JerseyBio-Rad QC Level 1-5mlReagentNos02/12/202456040
18BangkokBio-Rad QC Level 2-5mlReagentNos02/12/202456046
19BangaloreBlood Culture Broth-20mlReagentNos02/12/202456047
20New JerseyBlood Culture Broth-70mlReagentNos02/12/202456048
21BangkokBT Cleaning SolutionReagentNos02/12/202456049
22BangaloreBT Washing SolutionReagentNos02/12/202456050
23BangkokBudsReagentNos02/12/202456051
24BangaloreCalcium Chloride-10mlReagentNos02/12/202456052
25TokyoCartridge BG10-25TReagentNos02/12/202456053
26DelhiCedarwood Oil-25mlReagentNos02/12/202456054
27OhioChloride-25TReagentNos02/12/202456055
28New JerseyCoralyser CuvettesReagentNos02/12/202456056
29BangkokCoralyzer Surfactant-2X75mlReagentNos02/12/202456058
30BangaloreCover SlipReagentNos02/12/202456059
31New JerseyDeionized Water-20LtrReagentNos02/12/202456062
32BangaloreDiluent-20Ltr (Matrix 5 Part)ReagentNos02/12/202456063
33BangkokDiluent-20Ltr (Zybio Z3)ReagentNos02/12/202456064
34BangaloreDiluent-20Ltr (Zybio Z5)ReagentNos02/12/202456065
35TokyoAmikacin 30mcg-100's (AK30)ChemicalBox02/12/202456066
36SydneyAmoxicillin/Clavulanate 20/10mcg 100's (AMC20/10)ChemicalBox02/12/202456070
37IrelandAzithromycin 15mcg 100's (AZM15)ReagentBox02/12/202456072
38JapanAztreonam 30mcg 100's (AT30)ReagentBox02/12/202456073
39TokyoBacitracin-100'sReagentBox02/12/202456074
40DelhiCefazolin 30mcg 100's (CZ30)ReagentNos02/12/202456075
41OhioCefdinir 5MCG 100'sReagentNos02/12/202456076
42New JerseyCefepime 30mcg 100's (CPM30)ReagentNos02/12/202456077
43BangkokCefixime 5mcg 100'sReagentNos02/12/202456078
44BangaloreCefotoxime 30mcg 100's (CTX30)ReagentNos02/12/202456081
Sheet 1



Sheet 2 (Report)

Sample Data - 25-12-2024.xlsm
ABCDEF
1BranchProduct
2Branch to be selected using Data Validation -- Lista. A dropdown list of products from Col. B of Sheet 1 b. I need only the products list available against the branch selected in Cell A1 and should not display the products that are not available in the specific branch. c. Duplicate product names to be removed and only unique names to be available in the dropdown list. d. Option for autofill product names when one or more characters are typed. e. Dropdown list should not contain blank entries f. If possible Product names to be alphabetically displayed.
3
4
5
6Sl. NoTypeUOMDateInv. No.Price
71
82
93
104Need to display all items matching the Branch and Product criteria from sheet 1
115
126
137
148
159
1610
1711
1812
1913
2014
2115
2216
2317
2418
2519
2620
2721
2822
29
Sheet 2


This is only a sample data. Hope this is fine with you. Actually my database runs to more than 100000 rows.

Thanks & Regards
Subash D
 
Upvote 0
Validation list.xlsm
ABCDEFGHIJKLM
1BranchProductTypeUOMDateInv. No.PriceUnique BranchesBranch Products
2Sydney0.1ml 96 well PCR PlateGlasswareNos4562755970SydneyAVE-Cleanser II-40ml
3Ireland0.2ml 96 well PCR Plate-25'sGlasswareBox4562856013IrelandBiomedical Waste Cover Blue-Medium
4Japan0.2ml PCR 8 StripGlasswareBox4562856014JapanBlood Culture Broth-20ml
5Tokyo8 Strip CapsGlasswarePkt4562856018TokyoBT Washing Solution
6DelhiAcid Fast Stain KitChemicalBox4562856020DelhiCalcium Chloride-10ml
7OhioAutobio-Cuvette 1000'sReagentNos4562856021OhioCover Slip
8New JerseyAVE-Buffer 40mlReagentBox4562856022New JerseyDiluent-20Ltr (Matrix 5 Part)
9BangkokAVE-Cleanser I-500mlReagentBox4562856023BangkokDiluent-20Ltr (Zybio Z5)
10BangaloreAVE-Cleanser II-40mlReagentBox4562856024BangaloreCefotoxime 30mcg 100's (CTX30)
11New JerseyBarium Chloride 10% 500mlReagentBox4562856026  
12BangkokBenzidine Powder-25gmReagentNos4562856027  
13BangaloreBiomedical Waste Cover Blue-MediumReagentNos4562856029  
14TokyoBiomedical Waste Cover Green-SmallReagentNos4562856036  
15DelhiBiomedical Waste Cover Red-MediumReagentNos4562856037  
16OhioBiomedical Waste Cover Yellow-MediumReagentNos4562856039  
17New JerseyBio-Rad QC Level 1-5mlReagentNos4562856040  
18BangkokBio-Rad QC Level 2-5mlReagentNos4562856046  
19BangaloreBlood Culture Broth-20mlReagentNos4562856047  
20New JerseyBlood Culture Broth-70mlReagentNos4562856048  
21BangkokBT Cleaning SolutionReagentNos4562856049  
22BangaloreBT Washing SolutionReagentNos4562856050  
23BangkokBudsReagentNos4562856051  
24BangaloreCalcium Chloride-10mlReagentNos4562856052Calcium Chloride-10ml  
25TokyoCartridge BG10-25TReagentNos4562856053  
26DelhiCedarwood Oil-25mlReagentNos4562856054  
27OhioChloride-25TReagentNos4562856055  
28New JerseyCoralyser CuvettesReagentNos4562856056  
29BangkokCoralyzer Surfactant-2X75mlReagentNos4562856058  
30BangaloreCover SlipReagentNos4562856059  
31New JerseyDeionized Water-20LtrReagentNos4562856062  
32BangaloreDiluent-20Ltr (Matrix 5 Part)ReagentNos4562856063  
33BangkokDiluent-20Ltr (Zybio Z3)ReagentNos4562856064  
34BangaloreDiluent-20Ltr (Zybio Z5)ReagentNos4562856065  
35TokyoAmikacin 30mcg-100's (AK30)ChemicalBox4562856066  
36SydneyAmoxicillin/Clavulanate 20/10mcg 100's (AMC20/10)ChemicalBox4562856070  
37IrelandAzithromycin 15mcg 100's (AZM15)ReagentBox4562856072  
38JapanAztreonam 30mcg 100's (AT30)ReagentBox4562856073  
39TokyoBacitracin-100'sReagentBox4562856074  
40DelhiCefazolin 30mcg 100's (CZ30)ReagentNos4562856075  
41OhioCefdinir 5MCG 100'sReagentNos4562856076  
42New JerseyCefepime 30mcg 100's (CPM30)ReagentNos4562856077  
43BangkokCefixime 5mcg 100'sReagentNos4562856078  
44BangaloreCefotoxime 30mcg 100's (CTX30)ReagentNos4562856081  
45 
Sheet1
Cell Formulas
RangeFormula
L2:L44L2=IFERROR(INDEX($B$2:$B$44,AGGREGATE(15,6,ROW($B$2:$B$44)/(ISERROR(MATCH($B$2:$B$44,$L$1:$L1,0))*($A$2:$A$44=Sheet2!$A$2)),1)-ROW($B$1)),"")
K2:K45K2=IFERROR(INDEX($A$2:$A$44,AGGREGATE(15,6,ROW($A$2:$A$44)/(ISERROR(MATCH($A$2:$A$44,$K$1:$K1,0))),1)-ROW($A$1)),"")

Copy down Formulas in K2 and L2 Till row Number 44
Cell Formulas
RangeFormula
A7:A27A7=IF(LEN(B7)>0,SUM(A6)+1,"")
B7:F27B7=IFERROR(INDEX(Sheet1!C$2:C$44,AGGREGATE(15,6,ROW(Sheet1!$C$2:$C$44)/(ISNUMBER(MATCH(Sheet1!$A$2:$A$44,Sheet2!$A$2,0))*ISNUMBER(MATCH(Sheet1!$B$2:$B$44,Sheet2!$B$2,0))),ROWS($C$7:$C7))-ROW($C$1)),"")
Cells with Data Validation
CellAllowCriteria
A2List=OFFSET(Sheet1!$K$2,0,0,COUNTIF(Sheet1!$K$2:$K$100,"?*"))
B2List=OFFSET(Sheet1!$L$2,0,0,COUNTIF(Sheet1!$L$2:$L$100,"?*"))

Formulas in A6 , copy down.
Formula in B6 to be copied to full range.
Formua for Dv in A1
=OFFSET(Sheet1!$K$2,0,0,COUNTIF(Sheet1!$K$2:$K$100,"?*"))
Formula for Dv in B2
=OFFSET(Sheet1!$L$2,0,0,COUNTIF(Sheet1!$L$2:$L$100,"?*"))
 
Last edited:
Upvote 0
Validation list.xlsm
ABCDEFGHIJKLM
1BranchProductTypeUOMDateInv. No.PriceUnique BranchesBranch Products
2Sydney0.1ml 96 well PCR PlateGlasswareNos4562755970SydneyAVE-Cleanser II-40ml
3Ireland0.2ml 96 well PCR Plate-25'sGlasswareBox4562856013IrelandBiomedical Waste Cover Blue-Medium
4Japan0.2ml PCR 8 StripGlasswareBox4562856014JapanBlood Culture Broth-20ml
5Tokyo8 Strip CapsGlasswarePkt4562856018TokyoBT Washing Solution
6DelhiAcid Fast Stain KitChemicalBox4562856020DelhiCalcium Chloride-10ml
7OhioAutobio-Cuvette 1000'sReagentNos4562856021OhioCover Slip
8New JerseyAVE-Buffer 40mlReagentBox4562856022New JerseyDiluent-20Ltr (Matrix 5 Part)
9BangkokAVE-Cleanser I-500mlReagentBox4562856023BangkokDiluent-20Ltr (Zybio Z5)
10BangaloreAVE-Cleanser II-40mlReagentBox4562856024BangaloreCefotoxime 30mcg 100's (CTX30)
11New JerseyBarium Chloride 10% 500mlReagentBox4562856026  
12BangkokBenzidine Powder-25gmReagentNos4562856027  
13BangaloreBiomedical Waste Cover Blue-MediumReagentNos4562856029  
14TokyoBiomedical Waste Cover Green-SmallReagentNos4562856036  
15DelhiBiomedical Waste Cover Red-MediumReagentNos4562856037  
16OhioBiomedical Waste Cover Yellow-MediumReagentNos4562856039  
17New JerseyBio-Rad QC Level 1-5mlReagentNos4562856040  
18BangkokBio-Rad QC Level 2-5mlReagentNos4562856046  
19BangaloreBlood Culture Broth-20mlReagentNos4562856047  
20New JerseyBlood Culture Broth-70mlReagentNos4562856048  
21BangkokBT Cleaning SolutionReagentNos4562856049  
22BangaloreBT Washing SolutionReagentNos4562856050  
23BangkokBudsReagentNos4562856051  
24BangaloreCalcium Chloride-10mlReagentNos4562856052Calcium Chloride-10ml  
25TokyoCartridge BG10-25TReagentNos4562856053  
26DelhiCedarwood Oil-25mlReagentNos4562856054  
27OhioChloride-25TReagentNos4562856055  
28New JerseyCoralyser CuvettesReagentNos4562856056  
29BangkokCoralyzer Surfactant-2X75mlReagentNos4562856058  
30BangaloreCover SlipReagentNos4562856059  
31New JerseyDeionized Water-20LtrReagentNos4562856062  
32BangaloreDiluent-20Ltr (Matrix 5 Part)ReagentNos4562856063  
33BangkokDiluent-20Ltr (Zybio Z3)ReagentNos4562856064  
34BangaloreDiluent-20Ltr (Zybio Z5)ReagentNos4562856065  
35TokyoAmikacin 30mcg-100's (AK30)ChemicalBox4562856066  
36SydneyAmoxicillin/Clavulanate 20/10mcg 100's (AMC20/10)ChemicalBox4562856070  
37IrelandAzithromycin 15mcg 100's (AZM15)ReagentBox4562856072  
38JapanAztreonam 30mcg 100's (AT30)ReagentBox4562856073  
39TokyoBacitracin-100'sReagentBox4562856074  
40DelhiCefazolin 30mcg 100's (CZ30)ReagentNos4562856075  
41OhioCefdinir 5MCG 100'sReagentNos4562856076  
42New JerseyCefepime 30mcg 100's (CPM30)ReagentNos4562856077  
43BangkokCefixime 5mcg 100'sReagentNos4562856078  
44BangaloreCefotoxime 30mcg 100's (CTX30)ReagentNos4562856081  
45 
Sheet1
Cell Formulas
RangeFormula
L2:L44L2=IFERROR(INDEX($B$2:$B$44,AGGREGATE(15,6,ROW($B$2:$B$44)/(ISERROR(MATCH($B$2:$B$44,$L$1:$L1,0))*($A$2:$A$44=Sheet2!$A$2)),1)-ROW($B$1)),"")
K2:K45K2=IFERROR(INDEX($A$2:$A$44,AGGREGATE(15,6,ROW($A$2:$A$44)/(ISERROR(MATCH($A$2:$A$44,$K$1:$K1,0))),1)-ROW($A$1)),"")

Copy down Formulas in K2 and L2 Till row Number 44
Cell Formulas
RangeFormula
A7:A27A7=IF(LEN(B7)>0,SUM(A6)+1,"")
B7:F27B7=IFERROR(INDEX(Sheet1!C$2:C$44,AGGREGATE(15,6,ROW(Sheet1!$C$2:$C$44)/(ISNUMBER(MATCH(Sheet1!$A$2:$A$44,Sheet2!$A$2,0))*ISNUMBER(MATCH(Sheet1!$B$2:$B$44,Sheet2!$B$2,0))),ROWS($C$7:$C7))-ROW($C$1)),"")
Cells with Data Validation
CellAllowCriteria
A2List=OFFSET(Sheet1!$K$2,0,0,COUNTIF(Sheet1!$K$2:$K$100,"?*"))
B2List=OFFSET(Sheet1!$L$2,0,0,COUNTIF(Sheet1!$L$2:$L$100,"?*"))

Formulas in A6 , copy down.
Formula in B6 to be copied to full range.
Formua for Dv in A1
=OFFSET(Sheet1!$K$2,0,0,COUNTIF(Sheet1!$K$2:$K$100,"?*"))
Formula for Dv in B2
=OFFSET(Sheet1!$L$2,0,0,COUNTIF(Sheet1!$L$2:$L$100,"?*"))

Sir, you formula works fine in Col. K, but when copied your formula in Col. L, it is asking for source file (image given below)


1735187623237.png


Any changes to the formula to be done? Yet to try the formulas in Sheet 2.
 
Upvote 0
Also use this worksheet event code for Sheet1. Whenever A2 value changed in Sheet2 B2 value will become empty.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then Target.Offset(0, 1) = ""
End Sub
How to use worksheet event the code
Right click on Sheet tab --> view code
Visual Basic (VB) window opens.
Select worksheet in drop down instead of General
Paste the code
Close the VB window.
Save the file as .xlsm
 
Upvote 0
I have used sheet names as Sheet1 and Sheet2.
But Your sheet names are Sheet 1 and Sheet 2.
So in formulas Change Sheet1 as 'Sheet 1' and Sheet2 as 'Sheet 2'.
 
Upvote 0
Copied your code, but still it is asking for the source file

Sample Data - 25-12-2024.xlsm
ABCDEFGHIJKL
1BranchProductTypeUOMDateInv. No.PriceUnique BranchesBranch Product
2Sydney0.1ml 96 well PCR PlateGlasswareNos01/12/202455970Sydney 
3Ireland0.2ml 96 well PCR Plate-25'sGlasswareBox02/12/202456013Ireland 
4Japan0.2ml PCR 8 StripGlasswareBox02/12/202456014Japan 
5Tokyo8 Strip CapsGlasswarePkt02/12/202456018Tokyo 
6DelhiAcid Fast Stain KitChemicalBox02/12/202456020Delhi 
7OhioAutobio-Cuvette 1000'sReagentNos02/12/202456021Ohio 
8New JerseyAVE-Buffer 40mlReagentBox02/12/202456022New Jersey 
9BangkokAVE-Cleanser I-500mlReagentBox02/12/202456023Bangkok 
10BangaloreAVE-Cleanser II-40mlReagentBox02/12/202456024Bangalore 
11New JerseyBarium Chloride 10% 500mlReagentBox02/12/202456026  
12BangkokBenzidine Powder-25gmReagentNos02/12/202456027  
13BangaloreBiomedical Waste Cover Blue-MediumReagentNos02/12/202456029  
14TokyoBiomedical Waste Cover Green-SmallReagentNos02/12/202456036  
15DelhiBiomedical Waste Cover Red-MediumReagentNos02/12/202456037  
16OhioBiomedical Waste Cover Yellow-MediumReagentNos02/12/202456039  
17New JerseyBio-Rad QC Level 1-5mlReagentNos02/12/202456040  
18BangkokBio-Rad QC Level 2-5mlReagentNos02/12/202456046  
Sheet 1
Cell Formulas
RangeFormula
K2:K18K2=IFERROR(INDEX($A$2:$A$44,AGGREGATE(15,6,ROW($A$2:$A$44)/(ISERROR(MATCH($A$2:$A$44,$K$1:$K1,0))),1)-ROW($A$1)),"")
L2L2=IFERROR(INDEX($B$2:$B$215,AGGREGATE(15,6,ROW($B$2:$B$215)/(ISERROR(MATCH($B$2:$B$215,$L$1:$L1,0))*($A$2:$A$215=Sheet2!$A$2)),1)-ROW($B$1)),"")
L3:L18L3=IFERROR(INDEX($B$2:$B$215,AGGREGATE(15,6,ROW($B$2:$B$215)/(ISERROR(MATCH($B$2:$B$215,$L$1:$L2,0))*($A$2:$A$215=Sheet2!$A$2)),1)-ROW($B$1)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
'Sheet 1'!_FilterDatabase='Sheet 1'!$A$1:$A$10000K2:K18
 
Upvote 0
Thanks So much Mr. Murthy.

Your codes and formula's returned values as expected.

Only issue is due to the large data (20000 rows approx), excel is taking too much time to calculate and return values, otherwise, I am able to prepare the required reports easily.
 
Upvote 0

Forum statistics

Threads
1,225,902
Messages
6,187,728
Members
453,436
Latest member
MEZHH

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