Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel - Dynamically changing list boxes

Posted on 2013-01-24
3
Medium Priority
?
393 Views
Last Modified: 2013-01-25
Experts:

I have attached a sample Excel workbook.  I want to be able to work with 5 drop down lists.  All of the lists are the same.  There are 5 items in each of the dropdowns, and at any given time, each dropdown list item displayed will NOT be duplicated in any of the other 4 dropdowns.  I want to be able to select any of 5 items in a specific dropdown list, and have the items "swap".

I know above is not a very good explanation.  Hopefully the sample attached will show what I need better than this explanation.

Thanks in advance.

Rick Norris
DropDownExample.xls
0
Comment
Question by:Rick Norris
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 38817685
Try this macro
Right-click on the sheet tab name
Select View code
Paste this code in the VBA window
Close the VBA window
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cel As Range
    Dim scel As Range
    Dim dv
    Dim dvn() As String
    Dim nf As Boolean
    If Target.Count = 1 And Not Intersect(Target, Range("G1:K1")) Is Nothing Then
        For Each cel In Range("G1:K1")
            If cel.Address <> Target.Address Then
                If cel = Target Then
                    dvn = Split(Replace(ThisWorkbook.Names(Replace(cel.Validation.Formula1, "=", "")).RefersTo, "=", ""), "!")
                    For Each dv In Sheets(dvn(0)).Range(dvn(1))
                        nf = False
                        For Each scel In Range("G1:K1")
                            If scel = dv Then nf = True: Exit For
                        Next scel
                        If Not nf Then cel = dv: Exit Sub
                    Next dv
                End If
            End If
        Next cel
    End If
End Sub

Open in new window

0
 

Author Comment

by:Rick Norris
ID: 38818771
ssaqibh:

Just a very quick post to thank you for the above....  At present, I have not had an opportunity to try.  It will be very late this evening before I can test.

I just did not want you to think I am ignoring your post.

Thanks again,
Rick Norris
0
 

Author Closing Comment

by:Rick Norris
ID: 38820903
ssaqibh:

EXCELLENT, EXCELLENT solution.  It met every requirement!

After I looked at what I really need to happen, I now need additional help....  I've posted a follow up question.  I do hope that you can "modify" the code to accommodate my additional requirement that was not part of this original question.  I have provided a link to the new question.      
   

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28009497.html

Thanks again for the very prompt solution to my problem!!

Rick Norris
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question