?
Solved

Excel:  Dynamically changing drop down items AND data for the items.

Posted on 2013-01-25
3
Medium Priority
?
449 Views
Last Modified: 2013-01-26
Experts:

I asked a previous question.  Was answered completely...  this is a followup.  You may want to refer to below, and the solution.

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

Additional question:

I would now like to have the data in columns g thru k also move when the dropdown item list changes.

Please see attached Excel file for example of what I need.  Please see code behind the "data" tab for what is working currently...  Code was very kindly provided by ssaqibh!

thanks in advance.

Rick D Norris
DropDownExample---New.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 2000 total points
ID: 38821600
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
    Dim tmp As Variant
    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
                            tmp = Target.Offset(1).Resize(Target.End(xlDown).Row - Target.Row).Value
                            Target.Offset(1).Resize(Target.End(xlDown).Row - Target.Row).Value = cel.Offset(1).Resize(cel.End(xlDown).Row - cel.Row).Value
                            cel.Offset(1).Resize(cel.End(xlDown).Row - cel.Row).Value = tmp
                            Exit Sub
                        End If
                    Next dv
                End If
            End If
        Next cel
    End If
End Sub
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38821604
This will work if there are no gaps in the data

and

the heights of all columns are the same
0
 

Author Closing Comment

by:Rick Norris
ID: 38822133
ssaqibh:

‘Dwarfs standing on the shoulders of giants see farther ahead than the giants.’ Pascal

I am a dwarf, but with your help, my software project has been enhanced well beyond what I was capable

My example did not take into account the very HIGH probability of "gaps".... concerning heights......  Not sure if I understand???

Because the constraint you mentioned in your solution would not work in what I want as an end product, I am posting another follow-up question.  I have included an example that is a sampling of data that is representative of what I will be importing into my software.

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

You continued participation is very much appreciated.

Thanks again,
Rick Norris
0

Featured Post

Technology Partners: 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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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 demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

764 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