Solved

Excel - Dynamically changing list boxes

Posted on 2013-01-24
3
387 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

Industry Leaders: 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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

624 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