MACRO: Gather from other workbook IF criteria met

  • Thread starter Thread starter Legacy 171839
  • Start date Start date
L

Legacy 171839

Guest
Hi there,

I have a macro which opens up lots of workbooks, copies a specific range, then posts the info back into the 'master' workbook.

I would like to amend it so that when it opens the other workbooks, it will only copy the specified range, if the date in cell A2 = yesterdays date.

Have tried a few things and getting no where. Can anyone please help. Part of Macro am currently using as follows:

Code:
' GiftList_All_Gather Macro
    ChDir "W:\Shared-Data\Gift-List\GiftList Data Capture\Chris Campbell"
    Workbooks.Open Filename:= _
        "W:\Shared-Data\Gift-List\GiftList Data Capture\Chris Campbell\Chris Campbell.xls"
    Range("A2:K151").Select
    Selection.Copy
    Windows("GiftList Data Master.xlsm").Activate
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Windows("Chris Campbell.xls").Activate
    Application.DisplayAlerts = False
    ActiveWindow.Close
    Application.DisplayAlerts = False
    'done chris
    'start nicola
    Sheets("Nicola Taylor").Select
    ChDir "W:\Shared-Data\Gift-List\GiftList Data Capture\Nicola Taylor"
    Workbooks.Open Filename:= _
        "W:\Shared-Data\Gift-List\GiftList Data Capture\Nicola Taylor\Nicola Taylor.xls"
    Range("A2:K151").Select
    Selection.Copy
    Windows("GiftList Data Master.xlsm").Activate
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Windows("Nicola Taylor.xls").Activate
    ActiveWindow.Close
    Application.DisplayAlerts = False
    'done nicola
and so on...............

Thanks in advance...
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi Frierpie

I can't help but have tried to achieve something similar in the past (unsuccessfully).

I'm very interested to see any responses.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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