Solved

Excel - Dynamically changing list boxes

Posted on 2013-01-24
3
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

752 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