Link to home
Start Free TrialLog in
Avatar of Bright01
Bright01Flag for United States of America

asked on

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
Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image

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...
Avatar of Bright01

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You nailed it!  Thanks very much..... excellent work...and fast.

B.