Data Validation Drop Down List - Allow Duplicates

ronie85

Board Regular
Joined
Jan 25, 2014
Messages
96
Office Version
  1. 365
Platform
  1. Windows
Hi I am hoping someone will know this.

I have a data validation list for a change of a product outside of the generic product, meaning I want the first item on the list to be a = to the main generic product (which changes to other products on the list) and the rest of the items are all the products including the default generic product.
This means that it is defaulted until I manually change it to something else on the list.

The list should be;

= to Product 3
Product 1
Product 2
Product 3
Product 4
Product 5

The problem is that the list doesnt allow duplicates therefore the list like this;

Product 3
Product 1
Product 2
Product 4
Product 5

I would like it to be like the first list so that it is always defaulted to the generic product and the drop down box is only used to change the product.

At the moment when I set it to the first line, = Product 3, although this is the first selection, it is actually at the 4th line Product 3 therefore when the generic selection is changed elsewhere in the sheet, the list remains the same.

Can anyone help me to allow the data validation list to show all selections including the duplicate so that this works as I need it to?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How are you creating the data validation list?

I can easily create the situation you are describing, so I have a feeling there is a lot you are not describing.

Set the cell to a default of
=C4
Create the data validation list

1700753408690.png


Now select from the dropdown:

1700753484884.png
 
Upvote 0
Hopefully this explains it better

The blue list is the default list for which the red list should always default to this unless changed otherwise.
Cell G12 of List 2 (the list in question) equals the drop down selection of Cell B3 for List 1.

1700754707489.png


As you can see, List 2 should show 2 x Product 3's as it appears as the default linked to B3, and it also appears in the actual list G15.
Though the list excludes the 2nd reference therefore it can't sit naturally defaulted to B3 as it won't recognize both of the same name.

1700754742832.png
 

Attachments

  • 1700754655957.png
    1700754655957.png
    24.6 KB · Views: 16
Upvote 0
Zeszyt1
ABCDEFGHI
1Product 1A
2For Product 3:Product 2B
3Product 3Product 3C
4Product 4
5For Product 2:Product 5
6Product 2
7For Product 1:
8Product 1
9Other Validation list:
10B
Arkusz1
Cells with Data Validation
CellAllowCriteria
B3List=$G$1:$G$5
D6List=$G$1:$G$5
A8List=$G$1:$G$5
D10List=$I$1:$I$3


Assuming that there is such a moment when the form (sheet) is prepared for re-filling. I assumed that at this point we want to restore the default values for each of the cells in yellow. I assigned the following macro to the button on the sheet.
VBA Code:
Sub RestoreToDefault()
    Dim wks As Worksheet
    Dim rngSpecimen As Range
    Dim rng As Range
    Dim rngSource As Range
    Dim lDefaultPos As Long

    Set wks = ActiveSheet

    With wks
        
        Set rngSpecimen = wks.Range("B3")

        'the range of cells that are the source of the validation list
        Set rngSource = wks.Range(rngSpecimen.Validation.Formula1)
        
        'loop through all cells that have the same validation list as cell B3
        For Each rng In rngSpecimen.SpecialCells(xlCellTypeSameValidation)
            lDefaultPos = 0

            'defining a default validation list item for a given cell
            Select Case rng.Address(0, 0)
            Case "B3"
                lDefaultPos = 3
            Case "D6"
                lDefaultPos = 2
            Case "A8"
                lDefaultPos = 1
            End Select

            If lDefaultPos > 0 Then
                'if the default value has been defined
                rng.Value = rngSource.Cells(lDefaultPos).Value
            Else
                'No default value is defined, so clear the cell
                rng.ClearContents
            End If

        Next rng
        
    End With
End Sub
Artik
 
Upvote 0
How is the data validation for List 2 in cell G3 defined? Please give the actual formula.
 
Upvote 0

Forum statistics

Threads
1,223,863
Messages
6,175,049
Members
452,606
Latest member
jkondrat14

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