Solved

macro to refresh data in all 35 worksheets same work book

Posted on 2013-11-06
5
306 Views
Last Modified: 2013-11-07
Hi Experts
using Access and Excel 2003

I currently have an excel workbook with 35 sheets that are linked to different access qrys which I manually refresh each day.

I need a macro, so when the workbook is opened it automatically refreshes excel with the most current data from each of the qtys from ms access.

in each sheet row one is headers and then data from row 2 onwards.
0
Comment
Question by:route217
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
mikeyd234 earned 350 total points
ID: 39627264
This should work:
Sub calcSheets()

  Dim WS_Count As Integer
  Dim I As Integer

  ' Set WS_Count equal to the number of worksheets in the active
  ' workbook.
  WS_Count = ActiveWorkbook.Worksheets.Count

  ' Begin the loop.
  For I = 1 To WS_Count

    ActiveWorkbook.Worksheets(I).EnableCalculation = False
    ActiveWorkbook.Worksheets(I).EnableCalculation = True

  Next I

End Sub

Open in new window

0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 150 total points
ID: 39627272
Hi,

pls try

Application.ScreenUpdating = False
ActiveWorkbook.RefreshAll
Application.ScreenUpdating = True

Open in new window

0
 
LVL 3

Expert Comment

by:mikeyd234
ID: 39627279
Ignore my first post, use this one liner :)

ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources

Open in new window


You can add that into the workbook open event or into a sub :P

More info:
http://msdn.microsoft.com/en-us/library/office/ff195741.aspx
0
 

Author Comment

by:route217
ID: 39628005
thinks for the feedback let me test.
0
 

Author Comment

by:route217
ID: 39629800
Hi Experts

silly question if I have 7 worksheet s what line of code do I change to accommodate. .
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now