Solved

Excel - Dynamically changing list boxes

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Control calculations in Excel using VBA 4 16
time format showing wrong 12 50
Excel case statements 3 24
Export Query data to excel file 14 35
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 …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

911 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

24 Experts available now in Live!

Get 1:1 Help Now