<<Convert Excel Spreadsheets to Web Pages | Trading Software That Operates Within Excel | Convert Excel, Access & Other Databases | Merge Excel Files>>
Ozgrid, Experts in Microsoft Excel Spreadsheets

Decreasing Validation Lists

| | Information Helpful? Why Not Donate.

TRY OUT: Smart-VBA | Code-VBA | Analyzer-XL | Downloader-XL | Trader-XL| More Free Downloads.. Best Value: Finance Templates Bundle

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

Got any Excel Questions? Free Excel Help

See Also: Stop/Prevent Duplicates in Excel || Stop/Prevent Blanks in Excel || Dependent Validation Lists

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 CodeName . 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 is on the same Worksheet as the Worksheet_Change code resides

Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money

Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to [email protected] 31 days after purchase date.


Instant Download and Money Back Guarantee on Most Software

Try out: Analyzer XL | Downloader XL | Smart VBA | Trader XL Pro (best value) | ConsoXL | MergeXL | O2OLAP for Excel | MORE>>

Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!

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

Some of our more popular products are below...
Convert Excel Spreadsheets To Webpages | Trading In Excel | Construction Estimators | Finance Templates & Add-ins Bundle | Code-VBA | Smart-VBA | Print-VBA | Excel Data Manipulation & Analysis | Convert MS Office Applications To...... | Analyzer Excel | Downloader Excel | MSSQL Migration Toolkit | Monte Carlo Add-in | Excel Costing Templates