Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default Macro to refresh data from different files

Hello,

I have a standard chart and data on several files, 1 file for each product.
The data for each file is imported from Access. I created a master file which
link the data from each product file. How do I create a macro to go to all
the product files, to refresh all the data which in turn will update the
master file? Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Macro to refresh data from different files

On Tue, 18 Mar 2008 06:36:03 -0700, Cam
wrote:
I have a standard chart and data on several files, 1 file for each product.
The data for each file is imported from Access. I created a master file which
link the data from each product file. How do I create a macro to go to all
the product files, to refresh all the data which in turn will update the
master file? Thanks


Are they all in the same directory? Do they all have similar names? How
would you identify which files to open?
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
  #3   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default Macro to refresh data from different files

Hi Dick,

All files are in a same folder on the same network directory, but they all
have a different file name. So, instead of having to open all the files then
click a fresh all button on each file, I want a master macro to go in each
file and refresh the pivot tables, etc..

"Dick Kusleika" wrote:

On Tue, 18 Mar 2008 06:36:03 -0700, Cam
wrote:
I have a standard chart and data on several files, 1 file for each product.
The data for each file is imported from Access. I created a master file which
link the data from each product file. How do I create a macro to go to all
the product files, to refresh all the data which in turn will update the
master file? Thanks


Are they all in the same directory? Do they all have similar names? How
would you identify which files to open?
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Macro to refresh data from different files

On Wed, 19 Mar 2008 11:24:08 -0700, Cam
wrote:

Hi Dick,

All files are in a same folder on the same network directory, but they all
have a different file name. So, instead of having to open all the files then
click a fresh all button on each file, I want a master macro to go in each
file and refresh the pivot tables, etc..

Are they all in the same directory? Do they all have similar names? How
would you identify which files to open?


Cam: This isn't tested, so let me know if you run into troubles with it.
Change sFldr to point to the right place.

Sub RefreshAllFiles()

Dim sFldr As String
Dim ws As Worksheet
Dim pt As PivotTable
Dim sFile As String
Dim wb As Workbook

sFldr = "\\Server1\MyFolder\*.xls"

sFile = Dir(sFldr) 'get the first xls file

Do Until Len(sFile) = 0
Set wb = Workbooks.Open(sFile)
For Each ws In wb.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
wb.Save
wb.Close False
sFile = Dir 'get the next xls file
Loop

End Sub
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data import from different excel files & automatic refresh Aspa Excel Discussion (Misc queries) 0 April 23rd 08 09:30 AM
macro to refresh data Cam Excel Programming 1 February 21st 08 06:46 PM
Macro to refresh data sahafi Excel Programming 3 September 18th 06 06:04 PM
Macro to Open the Menu Data,Refresh Data,filename,import Bob Excel Programming 0 February 11th 06 04:51 PM
Run Macro on External Data Refresh John Witte Excel Programming 3 December 3rd 03 01:42 PM


All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"