Copying worksheet data based on drop down list

diannk

New Member
Joined
Aug 2, 2007
Messages
40
Good evening,

I am trying to complete a small project and have run into a bit of an issue. I have one sheet that contains 7 columns and 100 rows. In this sheet I have employee name, job site, and hours for M-F. I have another sheet in the same workbook that allows the user to select the job site - what I would like to do is have the data in sheet 1 populate in sheet 2 if the job site in sheet 1 is the same as the selection in sheet 2.

Thank you in advance,
Diann
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Diann

Welcome to the MrExcel board!

I believe this could be done with a macro or with formulas. Do you care which method?

In Sheet1 is the data in columns A:G? If not, where?

In Sheet2:
a) what cell is the selection of site in?
b) what columns is the data to go into?
 
Upvote 0
Thanks Peter,

Makes no difference to me which one, either macro or formula. In sheet 1 the data is in columns A:G. In sheet 2 the selection is in cell A1, the data should start in A6:G6.

Thanks again,
Diann
 
Upvote 0
Thanks Peter,

Makes no difference to me which one, either macro or formula. In sheet 1 the data is in columns A:G. In sheet 2 the selection is in cell A1, the data should start in A6:G6.

Thanks again,
Diann
Try this macro then. Modifications may be needed if, for instance, the code is to be run multiple times and the amount of data to be copied across could reduce. In this case some code to clear the data from Sheet2 (row 6 down) before the new data is copied across may need to be added. Anyway, give it a go and post back if you need further help.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> CopySiteData()
    <SPAN style="color:#00007F">Dim</SPAN> ws1 <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> ws2 <SPAN style="color:#00007F">As</SPAN> Worksheet
    <SPAN style="color:#00007F">Dim</SPAN> lr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> Site <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    
    <SPAN style="color:#00007F">Set</SPAN> ws1 = Sheets("Sheet1")
    <SPAN style="color:#00007F">Set</SPAN> ws2 = Sheets("Sheet2")
    lr = ws1.Range("B" & Rows.Count).End(xlUp).Row
    Site = ws2.Range("A1").Value
    
    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
    <SPAN style="color:#00007F">With</SPAN> ws1.Range("A1:G" & lr)
        .AutoFilter Field:=2, Criteria1:="=" & Site
        .Copy Destination:=ws2.Range("A6")
        .AutoFilter
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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