Populate table from another table based on drop down list selection

Ashleimo

New Member
Joined
Dec 4, 2017
Messages
11
Essentially what I am trying to do is copy a table from one worksheet to another based on a selection from a drop down list. I would like for each time the drop down option is changed the table is changed.

For example:
Worksheet1
A1=Quarter 1 (Chosen from drop down list)

A2= Table named Quarter 1 pulls from Worksheet 2

Hopefully that is clear. I'm open to all options!
 
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 5-24-18 6:45 PM EDT
If Not Intersect(Target, Range("A1")) Is Nothing Then
Application.ScreenUpdating = False
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
MsgBox "Hello now I will look for a Table named  " & Target.Value
Dim ans As String
Dim x As Long
x = 0
ans = Target.Value
Dim TT As ListObject
ans = Target.Value
    For i = 1 To Sheets.Count
    
        With Sheets(i)
            For Each TT In Sheets(i).ListObjects
                If TT.Name = ans Then
                TT.Range.Copy
                Sheets(1).Range("B1").PasteSpecial xlValues
                Sheets(1).Range("B1").PasteSpecial Paste:=xlPasteFormats: x = x + 1
                 Exit Sub
                 End If
                 
            Next
        End With
    Next
    If x = 0 Then MsgBox "I found no table named  " & Target.Value
Application.ScreenUpdating = True
End If
End Sub




GENIUS! Thank you so much!
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,948
Messages
6,175,569
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top