Decreasing Validation Lists

< Back to Search results

 Category: [Excel]  Demo Available 

Decreasing Validation Lists


Decreasing Validation List in Excel. Create a Diminishing/Decreasing Validation List.

Got any Excel/VBA Questions? Free Excel Help

Decreasing Data Validation Lists

If you need to have a list of options that decreases as users select from it, you can use data validation and some Excel VBA code.

On any Worksheet add your list, say in A1:A10. Now select this range and click in the Name Box (left of the Formula bar), type the name: MyList and then Enter. This will give you a named range called MyList.

Now select the range on another Worksheet where you would like the Validation Lists to go. Now right click on this sheet name tab, select View Code and paste in the code below:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strVal As String

Dim strEntry As String

    On Error Resume Next

        strVal = Target.Validation.Formula1

            If Not strVal = vbNullString Then

                strEntry = Target

                Application.EnableEvents = False

                With Sheet1.Range("MyList")

                    .Replace What:=strEntry, Replacement:="", _
                      LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False

                    .Sort Key1:=.Range("A1"), Order1:=xlAscending, Header:=xlNo, _
                      OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

                    .Range("A1", .Range("A65536").End(xlUp)).Name = "MyList"

                End With

            End If

        Application.EnableEvents = True

    On Error GoTo 0

End Sub

You should note that I have referred to the named range MyList as Sheet1.("MyList"). I have preceded the named range with its sheet code name. The reason for this is that the reference to the named range (MyList) is in the Private Module of another Worksheet. Without it, Excel would assume MyList 


See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets


See also:

Return The Weekday of Date in Excel
Debug VBA Code
Debug, Evaluate/Audit & Fix Excel Formula Errors


Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft.


stars (0 Reviews)