Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-25
3
Medium Priority
?
452 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

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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 will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

636 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