Moving Data from one WS to another

EE Pros,

I have a Workbook with 3 Worksheets.  I'm trying to select an Industry on the Splash Screen, have it match up to a range, and then place the new data from a DB (where the range is named), and place it in the third Worksheet.

Please take a look at the sample Attached.

Thank you in advance.

B.
Matching-up-Data-from-a-DB.xlsm
Bright01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
You can use the following code to do what you are looking for...

Sub copydata()

    Dim rng As Range
    Dim ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet
    Dim str As String

    Set ws = Sheets("Splash")
    Set ws1 = Sheets("Database")
    Set ws2 = Sheets("Cases")

    str = Application.WorksheetFunction.VLookup(ws.Range("n16").Value, ws.Range("X8:Y10"), 2, 0)

    Set rng = ws1.Range(str)

    rng.Copy ws2.Range("G5")

End Sub

Open in new window


Saurabh...
0
Bright01Author Commented:
Saurabh,

Thanks for jumping in....however, I don't believe that will work as a automatic macro.  If you look at the code I provided, you will see it looks for a change in the cell N16 for a particular Industry that then triggers the move.

Please take a relook.

Thank you,

B.
0
Saurabh Singh TeotiaCommented:
Replace your current splash code which you have in that module with this... This will do what you are looking for...

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
  
        Dim r As Long
        Dim rng As Range
        Dim ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet
        Dim str As String

        If Target.Address = "$N$16" And Trim(Target.Value) <> "" Then
            On Error Resume Next

            Set ws = Sheets("Splash")
            Set ws1 = Sheets("Database")
            Set ws2 = Sheets("Cases")

            str = Application.WorksheetFunction.VLookup(ws.Range("n16").Value, ws.Range("X8:Y10"), 2, 0)

            Set rng = ws1.Range(str)

            rng.Copy ws2.Range("G5")

        End If
  
End Sub

Open in new window


Saurabh...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bright01Author Commented:
You nailed it!  Thanks very much..... excellent work...and fast.

B.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.