updating sheets from another workbook

JD-dunks

New Member
Joined
Sep 1, 2011
Messages
2
I'm looking for a bit of code which updates sheets from other excel books which I'm downloading regularly.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I.e. <o:p></o:p>
<o:p> </o:p>
Look for workbook with naming convention and latest date<o:p></o:p>
update sheets in current workbook from the latest downloaded workbook with the same sheet name in this other workbook…<o:p></o:p>
<o:p> </o:p>
I don't want to update cell by cell, I want to replace the entire sheet for a number of sheets<o:p></o:p>
<o:p> </o:p>
Purpose being I have a report template which pulls data from the underlying sheets which I want to regular update.<o:p></o:p>
<o:p> </o:p>
Is there something quick for this?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Just further to this....
I recorded a macro which quite crudely opens my test sheet and copies the data in to the sheet I want it, although I'm looking for something a little more sophisticated… I.e. something that looks for a filenameconvention with the report date.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
<o:p></o:p>
<o:p>This is what I did...</o:p>
<o:p> </o:p>
Sub UpdateData()<o:p></o:p>
ChDir _<o:p></o:p>
"I:\Barra Reports\Joey Test"<o:p></o:p>
Workbooks.Open Filename:= _<o:p></o:p>
"I:\Barra Reports\Joey Test\wfej-FD Asia ex-Japan-20110731.xls"<o:p></o:p>
Sheets("Risk Decomposition").Select<o:p></o:p>
Cells.Select<o:p></o:p>
Selection.Copy<o:p></o:p>
Windows("FD Asia ex Japan (wfej).xls").Activate<o:p></o:p>
Sheets("Risk Decomposition Report").Select<o:p></o:p>
Cells.Select<o:p></o:p>
ActiveSheet.Paste<o:p></o:p>
Sheets("Report").Select<o:p></o:p>
End Sub<o:p></o:p>
 
Upvote 0
Hello,

Here's how to do a filesearch including naming filter etc. using VBA:
HTML:
http://www.ozgrid.com/VBA/loop-through.htm

I would also recommend that you use objects for the 2 workbooks in order to prevent possible conflicts while copying etc. + when using objects you can avoid using the Select method.

Code:
    Dim wbSource As Workbook, wbDest As Workbook

BR,
perco
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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