Solved

macro to refresh data in all 35 worksheets same work book

Posted on 2013-11-06
5
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 51

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
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.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

710 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