Solved

macro to refresh data in all 35 worksheets same work book

Posted on 2013-11-06
5
340 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 52

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

617 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