views:

54

answers:

3

I'm comparing a lot of data for over 30 categories. Each category workbook is saved into 'MyFolder' with it's own distinctive name (the category). The data in the workbook is found on a sheet with the same name as the category: [Category.xls]CategoryYear_Final!

It seemed best to create a standard template that references the data and which produced the required graphs and layouts. It all worked well. The it was time to start the engines and make graphs for all the categories by amending the reference names...

Using FIND & REPLACE it's taking over 20 mins each workbook as there are over 32,000 places (two per cell) where the updates must take occur. Crikey!

Any sugestions on how this could possibly be done more quickly, or do I just need to settle in for a solid 20 hours of watching Excel struggle through.

Many thanks Michael.

A: 

Likely you need to disable calculations (as mentioned) and possibly other things like screen updates as well.

Anthony -GISCOE-
I'll look in to screen updates as well. Thanks
Mike
A: 

To disable calculations:

If you have Excel 2007 or later (with the Ribbon):

  • Go to the Ribbon menu (the circle thing at top left).
  • Click "Excel Options" near the bottom right.
  • Click the "Formulas" category
  • Under calculation options, select "Manual"
JYelton
With disabling calculations, would that mean Excel wouldn't update the graphs until I re-enabled the calculations again?
Mike
That's correct; though you can force calculations by pressing F9 or clicking "Calculate Now" (on the Formulas bar). Incidentally the Calculation Options are also on the Formulas bar, which I hadn't realized.
JYelton
+2  A: 

This is what I would do. Before doing the update:

Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

After doing the update:

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.CalculateFull

You might want to make sure that if there's a problem with your update, you catch the error and go through the re-enable routine anyway. For example, if you error and fail to re-enable Excel ScreenUpdating, it makes the session unusable to a user (although it can be fixed through the VBA editor immediate window if you know what to do).

Joel Goodwin
Just about to post the same. Chances are it is the redrawing of the charts, rather than the recalculation, that is slowing things down so much.
Lunatik
As a VBA novice are you creating a macro and putting the first code block in it? And then a second macro with the second code block? USe the first, update then use the second?
Mike
Error handling would be : On Error GoTo... And then errHandler would pop up a message allowing me to cancel the procedure?
Mike
I would probably have separate subroutines called SwitchOff and SwitchOn which are called by your Find/Replace macro. (Advanced Masterclass: What I actually do is have a special EventSuppressor class that has a startsuppress/killsuppress function that does all this; the Class_Terminate also calls the killsuppress routine in case an error has tripped and skipped the bit that in your macro that calls killsuppress when you finish. This isn't necessary, it's just the way I industrialise this process as I need to use it multiple times.)
Joel Goodwin
My current find/replace macro is my right index finger and my sense of direction with the mouse;) But I'll work on my macro skills if it will help with this task.
Mike
Aha. Although you could conceivably call these routines from the Macro button before and after you do the Find/Replace, it would be better to create a one-stop shop that does the whole shebang. Consider it an education =)
Joel Goodwin
One last point. As suggested by others, you could just try turning off the calculations through the Options->Calculation dialog, make them manual, do your Find/Replace, then turn them back on. To force the entire sheet to recalculate once the update is completed, hit CTRL+ALT+F9 for a mega-recalculate.
Joel Goodwin
Mike, missed your comment about "On Error GoTo". You should pop the error to screen so you can see what actually went wrong, but when it's done, it should call the routine that re-enables everything again and exits gracefully.
Joel Goodwin