If value selected on dropdown then copy range

excel_2009

Active Member
Joined
Sep 14, 2009
Messages
318
Hi All,

I have a drop down with 4 options, depending on which option is selected the corresponding sheetname would be selected and column A would be copied to the clipboard.

e.g the dropdown values are as follows ebay, amazon, otto, tesco and the sheetnames are the same

Any idea how this would work? :confused:

Many thanks!!!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I assume when you say I have a drop down you mean a Data Validation list
And since you did not say where this drop down is I assume it will be in Range("A1")
If not modify my script.
My script copies from Range A1 to the last value in column A
Not the entire column which would be 1.5 million cells
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab where you have the drop down
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  6/28/2019  12:20:39 AM  EDT
If Target.Address = Range("A1").Address Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
On Error GoTo M
Dim Lastrow As Long
Dim ans As String
ans = Target.Value
Lastrow = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row
Sheets(ans).Range("A1:A" & Lastrow).Copy
End If
Exit Sub
M:
MsgBox "There is no sheet named  " & ans
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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