Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel: Dynamically changing column data

Posted on 2013-01-26
4
Medium Priority
?
404 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
  • 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 2000 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

Independent Software Vendors: 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

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…
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 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.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

824 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