Solved

Excel - Dynamically changing list boxes

Posted on 2013-01-24
3
337 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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now