Solved

Excel: Dynamically changing column data

Posted on 2013-01-26
4
380 Views
Last Modified: 2013-01-26
Experts:

This is a followup from a prior question:

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

This is the second follow-up ...  the link to the original question is "inside" the above link.

The solution to the prior question completely solved my problem as asked; however it had constraints that will not allow it to work with my "real world" data; hence, this followup.

I am attaching an excel spreadsheet that contains a representative sample of the data that i will be importing into my software.  This example DOES NOT include the solution from the question referenced above.

ssaqibh:  I hope you stick around and solve this conundrum as you have so graciously done for the last two questions.

Sincerely,
Rick Norris
DropDownExample---3.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
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38822149
This will work for DV cells in the range D2:K2
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("G2:K2")) Is Nothing Then
        For Each cel In Range("G2:K2")
            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("G2:K2")
                            If scel = dv Then nf = True: Exit For
                        Next scel
                        If Not nf Then
                            cel = dv
                            tmp = Target.Offset(1).Resize(Target.EntireRow.Cells(1).End(xlDown).Row - Target.Row).Value
                            Target.Offset(1).Resize(Target.EntireRow.Cells(1).End(xlDown).Row - Target.Row).Value = cel.Offset(1).Resize(cel.EntireRow.Cells(1).End(xlDown).Row - cel.Row).Value
                            cel.Offset(1).Resize(cel.EntireRow.Cells(1).End(xlDown).Row - cel.Row).Value = tmp
                            Exit Sub
                        End If
                    Next dv
                End If
            End If
        Next cel
    End If
End Sub

Open in new window

0
 

Author Comment

by:Rick Norris
ID: 38822202
ssaqibh:

You first two solutions worked perfectly for the question asked....  I tried above....  now the drop downs are back as the original question posed....  I'm sure there is just some little thing in the code that is causing the problem....  Dropdown items do not "swap", as in your solution to the first question....  and the swapping of the data as you solved in the first follow-up question is not working now.....  even if I revert to "uniform" data as show in the second follow-up question....   If you could be so kind as to look over the code again it would be most appreciated....  At current time it is beyond my ability; however, I plan on spending some time with the code to truly understand what you have written.

Thanks again,
Rick Norris
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 38822226
Here is your file with my code
Copy-of-DropDownExample---3.xls
0
 

Author Closing Comment

by:Rick Norris
ID: 38822256
ssaqibh:

Once again....  you solution was flawless!!

I'm sure I did something "stupid" when I copied above code into my spreadsheet.

More thanks and "kudos" to you!!

Rick Norris
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

752 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