Copy Data From Master Workbook Based on 2 Cell Values in Current Workbook

newkid59

New Member
Joined
Jun 27, 2016
Messages
3
I am trying to export data from a master workbook, into my current workbook, based on 2 values in my current workbook.


Current Workbook:

C1: Employee
C2: Bob

D1: Month
D2: July


Workbook I need to get data from:

V1: Employee
S1: Month

Is there a way to write a macro in my current workbook, that will autofilter the data in the master workbook based on my two criteria (that I will need to change in the future), copy it, and paste it in a worksheet in the current workbook I am using?

So I want data from the master workbook to only copy data that are for Employee Bob and Month of July, and paste it in another sheet in my current workbook. The employee and month I will need to change every time I use the macro, so it will really just need to reference the cell value.

Please let me know if you have any questions. I've been trying to go about this the last day and a half and I'm not getting anywhere or finding older posts similar to my current situation.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I should say that I've been able to copy all of the data from data sheet in the master workbook into my current workbook with the code below. I just haven't figured out how to filter out the data first before copying and pasting it in my current workbook.

Sub openAndCopy()
Dim wbCopy As Workbook
Dim wscopy As Worksheet
Dim rngCopy As Range
Dim wbpaste As Workbook
Dim wspaste As Worksheet
Dim rngpaste As Range




Set wbCopy = Workbooks.Open("C:\.......\Master Workbook.xlsb") 'change path to master workbook
Set wscopy = wbCopy.Worksheets("Detailed List")
Set rngCopy = wscopy.Range("A:CR").EntireColumn
Set wbpaste = Workbooks(" Current Workbook.xlsb")
Set wspaste = wbpaste.Worksheets("Data")
Set rngpaste = wspaste.Range("A1")


rngCopy.Copy
rngpaste.PasteSpecial




wbCopy.Save
wbCopy.Close


End Sub
 
Upvote 0
you probably dont need vba to solve this... you just need to write lookup formulas directly into the current workbook that looks through the table on the master workbook based on criteria you have in cells on the current workbook.

If you show what your workbooks look like and what data you need to bring over you can most likely accomplish with a single formula that you drag down and across your table. No need for vba.
 
Upvote 0

Forum statistics

Threads
1,217,394
Messages
6,136,355
Members
450,006
Latest member
DaveLlew

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