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?
 
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
 
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
 
Bright01Author Commented:
You nailed it!  Thanks very much..... excellent work...and fast.

B.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.