This is a cute trick that can be used to impress your boss or co-workers, if they happen to be walking by. Just place any of these code blocks in the sheet module behind a worksheet, then click around the worksheet. Don't use a worksheet that already has cells with fill color, as these procedures will wipe them out.
Refreshing Pivot Tables
I have a certain workbook where I keep some statistics. I've created a small PivotTable, with a PivotChart attached to it. I like to have the chart update in real time, so I use a bit of code to do that. The following code goes in the sheet module for the particular sheet I want to update.
Instantiating Office Applications
In Office – Applications – Started!, Ralf Stolzenburg posted sample VBA code for instantiating several Office applications. I've written about this subject as well, in Easy Application.Object References.
I like my code better, because it avoids the global Object variables present in Ralf's code. (Although as we'll see later, at least one global Boolean variable may be required.) I'd prefer to have one routine create (and return) the object, then pass it to another routine that does something else. It's all part of the encapsulation and loose coupling attitude I've mentioned elsewhere.
Follow Me